php ini_set(“memory_limit”) isn’t working at all

If you are trying to set your php memory limit at the top of a php script using the php int_set() and it doesn’t appear to have any affect then there is a chance that you have the PHP Suhosin security extension installed. Suhosin stops a script from being able to increase the memory limit.

If you have the Suhosin extension installed then simply edit /etc/php5/conf.d/suhosin.ini and change:

;suhosin.memory_limit = 0


suhosin.memory_limit = 1G

Or however much memory you would like to allow for the script. Then restart nginx / or apache.

sudo service apache2 restart

Note – if you use int_set() and attempt to set a higher memory limit than allowed in the suhosin settings then it will no have any affect at all.

Leave a Reply