memory_limit

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
itjerry
Forum Newbie
Posts: 2
Joined: Thu Aug 10, 2006 10:51 pm

memory_limit

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the setting is per request. As in each request would have 32M of memory.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post 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.
itjerry
Forum Newbie
Posts: 2
Joined: Thu Aug 10, 2006 10:51 pm

Post by itjerry »

Thanks. :D
Post Reply