Allowed Memory Size of 262144 Bytes Exhausted (Tried to Allocate 24576 Bytes)

Allowed memory size of 262144 bytes exhausted (tried to allocate 24576 bytes)

I see my problem is a little bit different from yours, but I'll post this answer in case it helps someone else. I was using MB as shorthand instead of M when defining my memory_limit, and php was silently ignoring it. I changed it to an integer (in bytes) and the problem was solved.

My php.ini changed as follows: memory_limit = 512MB to memory_limit = 536870912. This fixed my problem. Hope it helps with someone else's! You can read up on php's shorthand here.

Good luck!

Edit

As Yaodong points out, you can just as easily use the correct shorthand, "M", instead of using byte values. I changed mine to byte values for debugging purposes and then didn't bother to change it back.

Allowed memory size of 262144 bytes exhausted

Try this: ini_set('memory_limit','3072M');

Fatal Error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) on line 3

  1. Increase memory_limit in your php.ini file. If this is not resolving the issues:

2) Add this line ini_set('memory_limit', '-1'); before the line where you get the error

Out of memory (allocated 899678208) (tried to allocate 262144 bytes)

I think you are trying to call a parent in DB class from User. If your class extends another class then you do not need to redefine that method as long as it is not abstract. Just remove the login function from class User.

//function login($username , $password){
// return $this->login($username , $password );
//}

or you can call the parent using the following syntax:

return parent::login($username, $password);

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes)

Thanks For Everyone who tried to help me to solve this. Anyway I found the problem. It's my mistake: I have used the same method name inside of UserView.class.php and User.class.php. The method name is username_exists. Here is the problematic code.

//this is the method in modal class

protected function username_exists($username){

if($this->if_tableEmpty() != true){

$this->username = $username;


$sql = "SELECT username FROM user_login WHERE username = ?";

$stmt = $this->connect()->prepare($sql);

$stmt->execute([$this->username]);

$result = $stmt->rowCount();

return $result;
}else{
return 0;
}



}

//This is the method in Controller class

public function username_exists($username){

$this->username = $username;

$result = $this->username_exists($this->username);

if($result > 0){

return true;

}else{

return false;

}

}

Thanks again to all of you!

Fatal error: Out of memory (allocated 1872756736) (tried to allocate 262144 bytes)

Success. Return property - good .

public function getObjectManager()
{
return $this->objectManager;
}

Error. Return method - error and infinite loop

public function getObjectManager()
{
return $this->getObjectManager();
}


Related Topics



Leave a reply



Submit