Question


I am writing a script, where I need to set memory limit to something very high at a certain point. But, I need to restore memory limit after that.


But, ini_get returns -1 if your script has not called ini_set to set memory limit.
I am trying to do something like this :

$oldLimit  = ini_get("memory_limit");
ini_set("memory_limit", "220M");
do something 
//restore memory
ini_set("memory_limit", -1);

But, $oldLimit is -1.
what does -1 means in this scenario.
Thanks in advance.

Was it helpful?

Solution

-1 means unlimited, or in other words, you are limited by the server's physical memory. So there is no point in setting the memory_limit to something high

OTHER TIPS

According to the docs, -1 means there is no memory limit (http://ca.php.net/manual/en/ini.core.php)

(Having said that, there could be other memory resrictions causing you grief.)

Also, the ini_set() only applies for the duration of that running script, and isn't permanent, nor does it apply to any other scripts running at that time, or in the future. So if you do make changes, you probably don't need to set them back as they will just fall back when the script ends.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top