Page 1 of 1

memory_limit

Posted: Thu Aug 10, 2006 11:30 pm
by itjerry
Hi All,

I would like to ask the memory_limit attribute in php.ini. From http://php.chinaunix.net/manual/en/ini.core.php, it said:

memory_limit integer

This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. In order to use this directive you must have enabled it at compile time. So, your configure line would have included: --enable-memory-limit. Note that you have to set it to -1 if you don't want any limit for your memory.

if i set to 32M, does it mean each script has a 32M maximum amount of memory to execute?

if twenty people access to different scripts simultaneously,

max. amount of memory consumes = 20 * 32M = 640M

is it right ?

if i set the memory_limit too high, is it lead to memory overflow easily?

I am using Sun ONE Web Server 6.1.

Thanks.

Posted: Thu Aug 10, 2006 11:50 pm
by feyd
the setting is per request. As in each request would have 32M of memory.

Posted: Fri Aug 11, 2006 2:28 am
by AKA Panama Jack
Actually it is the MAXIMUM amount that each instance of PHP can allocate. It doesn't automatically allocate 32 meg. It will only use what is needed and allocate UP TO 32 meg if it is needed. So if your script only needs 2 meg then that is all that is used but if it needs 32 meg it can allocate it.

Posted: Fri Aug 11, 2006 8:25 pm
by itjerry
Thanks. :D