ini_set("memory_limit") in PHP 5.3.3 is not working at all

Ant picture Ant · Feb 21, 2011 · Viewed 230.8k times · Source

I had this working before :

echo ini_get("memory_limit")."\n";
ini_set("memory_limit","256M");
echo ini_get("memory_limit")."\n";

That would input this :

32M
256M

on a php script executed by command line. I updated from 5.2 to 5.3, and from now, this directive is not working at all : this gives me :

32M
32M

and then make my script fail with a fatal Error...

I checked the php documentation, and googled it, and I didn't find anywhere that "memory_limit" had been deprecated.

Does anyone have a solution?

Answer

Oscar M. picture Oscar M. · Mar 10, 2011

If you have the suhosin extension enabled, it can prevent scripts from setting the memory limit beyond what it started with or some defined cap.

http://www.hardened-php.net/suhosin/configuration.html#suhosin.memory_limit