PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

Dung Do Tien Oct 20 2021 49

I have a web application with PHP 7.x and Moodle. I try test in local my compute, everything work well.

After I deploy it into server Linux Ubuntu 20.04 I got an exception throw PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes)

 PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in \cache\stores\static\lib.php on

PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in \cache\stores\static\lib.php on line 261
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 40960 bytes) in \lib\classes\session\manager.php on line 530
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 28672 bytes) in \lib\classes\session\database.php on line

Cannot find session record pbs503lloa7c9gbrbfst2lcivd for user 4494, creating new session.
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in \m23\lib\classes\component.php on line 1040
Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in \cache\stores\static\lib.php on line 261
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 40960 bytes) in \lib\classes\session\manager.php on line 530
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 28672 bytes) in \lib\classes\session\database.php on line

I'm using PHP 7.1 and Moodle 3.3.

Thanks for any suggestion to solve this issue.

Have 3 answer(s) found.
  • S

    Sandeep Kumar Oct 20 2021

    This error throw because default setting is low and not enough memory to do.

    You can open file php html and add line code bellow into top of file:

     <?php ini_set('memory_limit', '1024M'); // or you could use 1G

    I hope it solve for you.

  • U

    Ubonwan Raksasat Oct 20 2021

    You can edit value of memory_limit in php.ini file. You need to increase it to double.

    Step 1. Run vi /etc/php.ini command in your Ubuntu server and change memory_limit to double. ex: change from 125M to 250M.

    Step 2. Run /etc/init.d/httpd restart command to restart Php server.

    I hope it solved for you.

  • א

    אופק סדלובסקי Oct 20 2021

    You can change memory_limit from .htaccess file. Open .htaccess file and change as below:

     vi ./.htaccess
    php_value memory_limit 256M

    It worked for me.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close