...

View Full Version : ini_set() an unlmited memory_limit question



Coastal Web
03-24-2010, 06:46 PM
Hi guys, l have a quick question, will using this in the top of your php script:

ini_set("memory_limit","0");
Make it so your php script has no memory_limit, or do you have to give it an actual number like this?


ini_set("memory_limit","999999999M");

Rowsdower!
03-24-2010, 07:43 PM
In theory, yes (according to what I've read about it). Setting the memory limit to zero will make it unlimited up to your hardware's max.

In practice, I don't exactly know. I have never actually tried it.

Coastal Web
03-24-2010, 07:48 PM
In theory, yes (according to what I've read about it). Setting the memory limit to zero will make it unlimited up to your hardware's max.

In practice, I don't exactly know. I have never actually tried it.

Thanks!

PS> IMHO you should add outline:none; to your default css reset (in your sig). I hate those dang outlines, especially when their on image replaced links using text-indent: -999px to hide the text ;)


* {border:0;margin:0;padding:0;outline:none;}

Rowsdower!
03-24-2010, 08:10 PM
Thanks!

PS> IMHO you should add outline:none; to your default css reset (in your sig). I hate those dang outlines, especially when their on image replaced links using text-indent: -999px to hide the text ;)


* {border:0;margin:0;padding:0;outline:none;}

No problem.

Oh and I often do use outline:none; actually, but you have to be careful to make sure that a similar functionality is put in its place with :active styles (for accessibility/user-friendliness reasons). Because of that I don't really include it in the default reset that I recommend to others since there isn't enough room in the sig to properly caution them about it. :D

I usually figure that they can discover that option on their own in good time.

Coastal Web
03-24-2010, 08:24 PM
Good points and nice snippet! Thanks.

Regards,

Fou-Lu
03-24-2010, 09:07 PM
Hi guys, l have a quick question, will using this in the top of your php script:

ini_set("memory_limit","0");
Make it so your php script has no memory_limit, or do you have to give it an actual number like this?


ini_set("memory_limit","999999999M");

I believe a memory limit of 0 is just that, no available memory to use. To use max memory available (quite unwise, so make sure you control it well), use -1 as you're memory limit; make sure its an integer -1 and not a string -1M for example.

Rowsdower!
03-24-2010, 09:38 PM
Whoopsie, you're right! According to the documentation:


Resource Limits
Resource Limits Name Default Changeable Changelog
memory_limit "128M" PHP_INI_ALL "8M" before PHP 5.2.0, "16M" in PHP 5.2.0


Here's a short explanation of the configuration directives.


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. Note that to have no memory limit, set this directive to -1.

Prior to PHP 5.2.1, in order to use this directive it had to be enabled at compile time by using --enable-memory-limit in the configure line. This compile-time flag was also required to define the functions memory_get_usage() and memory_get_peak_usage() prior to 5.2.1.

When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used.

See also: max_execution_time.


Sorry about that!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum