PHP Fatal error: Allowed memory size of 134217728 bytes exhausted
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.
-
S0
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.
-
U0
Ubonwan Raksasat Oct 20 2021
You can edit value of
memory_limit
inphp.ini
file. You need to increase it to double.Step 1. Run
vi /etc/php.ini
command in your Ubuntu server and changememory_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.
-
א0
אופק סדלובסקי 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.
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.