Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ini_set('memory_limit', ...) doesn't work and returns false; can't figure out why

ini_set('memory_limit', '128M'); // Returns false; memory_limit unchanged

I wasn't able to find a list of things that can cause this. So far I checked:

  • Safe mode: disabled
  • disable_functions: Empty
  • php_admin_value: None that I could find (is there a way to know for sure?)

I ran out of ideas! ini_set works correctly with other parameters (such as "display_errors")

like image 267
Thomas Bonini Avatar asked May 02 '11 16:05

Thomas Bonini


People also ask

How do I fix out of memory error in PHP?

Create a phpinfo. php file under root directory and check for current memory limits. By default memory limit is 8M, but in this case you have to increase the memory limits to 12M, 16M, 24M and so on with this line. This will increase your memory limit and solve this error.

What is ini_ set() in PHP?

The ini_set() function allows you to change system attributes that affect the way your script is executed. Changes only affect the current script, and will revert back when the script ends. To use ini_set() , pass it the value you want to change as its first parameter, and the new value to use as its second parameter.

What is the max memory limit for PHP?

Increasing the PHP memory limit The default memory limit is 256M and this is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file.


1 Answers

If it's not the PHP version problem posted already try checking that there's nothing on the machine preventing your from raising this limit.

How to check whether Suhosin is installed?

edit (after establishing that Suhosin is installed):

Config details are here: http://www.hardened-php.net/suhosin/configuration.html I suspect there'll be a file in /etc/php.d/ that you can edit to increase the memory limit bounds. The config variable you need to edit is: suhosin.memory_limit

like image 187
James C Avatar answered Sep 30 '22 13:09

James C