PHP memory fixed, although memory limit was not reached

I am currently debugging php-script. I set memory_limit to 64M and it confirms this:

ini_set("memory_limit","64M"); echo "starting script with ".ini_get("memory_limit")."Bytes of ram\n"; \\64 

But, nevertheless, the script breaks using only 20M, which leads to an error caused by standard memory.

 Fatal error: Allowed memory size of 20971520 byte exhausted 

Is there a possibility that I probably did not think about? Perhaps Apache is installing something for PHP?

+4
source share
2 answers

perhaps safe_mode enabled on your server - if so, many settings cannot be changed using ini_set() . look at your php.ini and check it out.

EDIT: what happens if you change the memory_limit value in php.ini directly and restart / reload your apache (or something else)? Does it work in this case?

EDIT2 in wuschelhases comment:

  • Did you restart apache after changing php.ini? Are you really sure you changed the correct php.ini (maybe not one)?
  • which OS works (is it a Linux server, a Windows server, or a simple xampp installation on your windows-home-pc)?
  • what does phpinfo () say about memory limit?
+3
source

Better try this for unlimited memory:

 ini_set("memory_limit",-1) 
+4
source

Source: https://habr.com/ru/post/1342779/


All Articles