Ini_set / ini_get memory_limit php memory recovery


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


But ini_get returns -1 if your script did not call ini_set to set a 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.

which means -1 in this scenario.

Thanks in advance.

+3
source share
2 answers

-1 means an unlimited number, or, in other words, you are limited by the physical memory of the server. Therefore, it makes no sense to set memory_limit to something high

+4

, -1 , (http://ca.php.net/manual/en/ini.core.php)

(, , ).

, ini_set() script , , . , , , , , , script.

+3

All Articles