PHP memory limit - 8MB ?

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
kaufmann

PHP memory limit - 8MB ?

Post by kaufmann »

A search showed that a number of people have asked this question -- but I have not seen any answers.  I hope it's OK if I post the question again.

My local development server is EasyPHP 1.8.01, a WAMP system (on Win2K SP4 or WinXP SP2 - both of which see this problem).  [The production server is 1and1.com's LAMP system. I do this development from Windows because I'm setting up a site for multiple editors (the same reason I came to CMSMS), and want to be sure that I see any problems they might see.]  When I installed CMSMS to my local server, the "Install System" page ran its tests and warned of two problems:
    - PHP memory limit    =  8M [recommended: 16M]
    - max upload file size =  2M [recommended: 10M]

So I edited php.ini to the recommended values and tried again -- but the "Install System" report still had a problem: Weirdly, it recognized only one of the two changes:
    - PHP memory limit    =  8M [recommended: 16M]
    - max upload file size = 10M [recommended: 10M]

Then I found that it did not matter what value I used to initialize PHP memory limit: I tried 16M, 32M, 4M ... everything was read as "8M".  So I suspected a problem with the way CMSMS tests this value, and searched for info on www.cmsmadesimple.org, and then on forum.cmsmadesimple.org ... and then I saw the unanswered questions on this issue. Still, let me try again: Anyone know what is going on here?

Also, what are the likely consequences?  8MB seems way more than enough space for any script I might write. Do they really get larger?
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: PHP memory limit - 8MB ?

Post by Dee »

Hello,
You did restart apache after making changes to php.ini?
If so PHP may be compiled without memory_limit support.

When PHP runs out of memory (or execution_time) it can cause serious trouble because the execution of the script it is running will be stopped. This could cause "white pages" (no content), error messages and even data corruption (when it happens in the middle of deleting/moving a lot of pages for example).

8M is reached very fast on current PHP versions, especially when UTF-8 is used (it is not a limit on the script filesize, but the memory needed/used to run the script).

Regards,
D
Vin

Re: PHP memory limit - 8MB ?

Post by Vin »

uh-huh... so if I switch to another encoding (for instance an iso norm), the memory usage will be lower?
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: PHP memory limit - 8MB ?

Post by Dee »

I don't think switching at that level will make a lot of difference.
Memory usage depends on a lot of things.
In my experience the 8M limit is reached sooner on a server with UTF-8 support than on one where the kernel and all software are compiled without.

Regards,
D
Last edited by Anonymous on Thu Mar 15, 2007 9:06 pm, edited 1 time in total.
kaufmann

Re: PHP memory limit - 8MB ?

Post by kaufmann »

Dee wrote: You did restart apache after making changes to php.ini?
Yes.  As I said, it was weird that one of the two changes (max upload file size) was recognized and one change (memory limit) was not.  Also as I said, others have reported the same problem (though I have not found answers for it posted).
If so PHP may be compiled without memory_limit support.
Yes? - then why include the parameter in php.ini?  IAC, at least it is a possible answer, so I will look into the possibility.
When PHP runs out of memory (or execution_time) it can cause serious trouble because the execution of the script it is running will be stopped. This could cause "white pages" (no content), error messages and even data corruption ... 8M is reached very fast on current PHP versions, especially when UTF-8 is used (it is not a limit on the script filesize, but the memory needed/used to run the script).
Yes, I understood we are talking about working memory, not filesize; sorry if my clumsy question seemed to imply otherwise.  I'm still surprised at the size, which begs a further question: If 8M is so easy to reach, how do we determine that 16M is safe?

Thanks for your reply,
John
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: PHP memory limit - 8MB ?

Post by Dee »

kaufmann wrote:
If so PHP may be compiled without memory_limit support.
Yes? - then why include the parameter in php.ini?  IAC, at least it is a possible answer, so I will look into the possibility.
Yes ;D  - and if it is there is no use in putting it in php.ini.
kaufmann wrote: If 8M is so easy to reach, how do we determine that 16M is safe?
16M is probably not what you could call "safe" - better set it to a decent value like 128M (the default in current PHP versions)

Regards,
D
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: PHP memory limit - 8MB ?

Post by Dee »

After some surfing & searching it seems this has come up before.

Windows PHP builds have support for memory_limit since 5.1.3 (I'm not sure if current PHP4 versions have support for it).
See this bug and this changelog.

Regards,
D
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: PHP memory limit - 8MB ?

Post by Nullig »

I usually add the following line to scripts that have memory allocation errors...

Code: Select all

ini_set("memory_limit", "16M");
Works for me - my host is on a linux server and has the default set to 8M.

Nullig
kaufmann

Re: PHP memory limit - 8MB ?

Post by kaufmann »

Dee wrote:
If 8M is so easy to reach, how do we determine that 16M is safe?
16M is probably not what you could call "safe" - better set it to a decent value like 128M (the default in current PHP versions)
I guess "safe" was not the right word for 16M -- install.php calls it "recommended", and it sounds like your recommendation is much higher.  I don't do any server administration, so I'm surprised by the memory requirements and totally clueless about this question:  When 128M is the limit for a single process, does the server provide some multiple of that for each concurrent user?

Regards,
- John
kaufmann

Re: PHP memory limit - 8MB ?

Post by kaufmann »

Dee wrote: After some surfing & searching it seems this has come up before.
Thanks!  I'm sorry that did not turn up in my earlier search, but it confirms your initial reply to my question, that PHP might be compiled without memory_limit support.  As I have since learned, that was the case.
Windows PHP builds have support for memory_limit since 5.1.3 (I'm not sure if current PHP4 versions have support for it).
See this bug and this changelog.
Nice catch!  As it said in the bug report, "Windows builds are made without enabling memory limit since the dawn of time." - a situation that only changed with the bug fix in PHP 5.1.3.

I hope others who might have this problem with Windows servers find this thread.

Regards,
John
kaufmann

Re: PHP memory limit - 8MB ?

Post by kaufmann »

Nullig wrote: I usually add the following line to scripts that have memory allocation errors...

Code: Select all

ini_set("memory_limit", "16M");
Works for me - my host is on a linux server and has the default set to 8M.
Thanks for the suggestion, but I tried adding that to config.php and include.php, with no luck -- for the simple reason, as Dee said, that in this case [for my local development server, under Windows] PHP was compiled without memory_limit support.  Still I will keep this in mind for my web host, in case needed.  I appreciate your mention of it.

Regards,
John
Vin

Re: PHP memory limit - 8MB ?

Post by Vin »

Hello, it's me again...
I'd like to know whether it is possible to find out how much memory the scripts use on the WAMP local development system. I would like to know the requirements in advance.
Locked

Return to “[locked] Installation, Setup and Upgrade”