Recent Topics

php5 defaults don't have enough memory

Thread started by , Mon Oct 4, 2010 13:34 – Last touched: Mon Oct 4, 2010 13:34
Started by , 10/4/10

Oct 4, 2010 13:34    

Using a clean install of Ubuntu, I installed apache2 and php5 (via apt-get). Then downloaded v4.0.0 alpha.

While installing, it crashed saying that there was insufficient memory. After some googling, I figured out that the default was 16M and that wasn't enough. I increased to 128M and started over and it worked ok.

The install instructions should warn you prior to beginning the install that you need to increase the memory limit. If you wanted to get fancy then it could tell you what the maximum memory currently is, similar to the backoffice => Tools => System.

Comment from:

128M is default in PHP 5. Did you use an old PHP 4 config file?

I moved the post to feature requests, it's not a bug.

10/05/10 @ 04:47

Comment from:

I ran a clean install of Ubunutu 9.10, and then used apt-get to install apache2 and php5. I did not change any defaults on anything -- the default was 16M.

I solved it by overriding the default in my apache2 configuration and restarting the server.

My point is that if the install requires a certain amount of memory then it would be helpful (and pretty easy) to indicate that on one of the install screens prior to crashing, regardless of what the defaults are in PHP5.

10/05/10 @ 13:50

Comment from:

I agree, there must be a check for memory and some functions that might be disabled in PHP.

10/05/10 @ 15:17

Comment from:

Do you guys want to add those necessary checks at the begining of the install script?

10/10/10 @ 20:10

Comment from:

fplanque wrote:

Do you guys want to add those necessary checks at the begining of the install script?

Seems like the reasonable place to put it.

10/10/10 @ 20:12

Comment from:

Yep I know, but do you want to implement that and contribute your code? ;)

10/10/10 @ 20:22

Comment from:

Where is the CVS (or SVN?) info so that I can connect to the repository?

Is there documentation for the development process somewhere? I assume you don't random people off the street just sticking code into the stream without someone sanity checking it first...

EDIT: Nevermind -- I found the CVS info to connect on sourceforge. I'm finishing up a plugin right now (just needs some more testing and code cleanup). Once that's done I'll I tinker with getting a sourceforge account and connected to CVS. Might be a bit of a delay, though, because work has been busy recently and I've got a couple business trips coming up.

10/11/10 @ 01:55

Comment from:

As requested, I've checked out the CVS branch as anonymous and made the change in install.php. The fast version is that I reused the existing function in _system.funcs.php to check the memory and die() if it's below 20M (my testing said that 16M crashes and 20M works), similarly to how the code checks PHP and MySQL versions.

How do I go about getting permissions to check it into CVS? Is there a code review process or something?

10/17/10 @ 23:23

Comment from:

I'll send him a message.

The change consists of two parts:

1. An include statement near the beginning of /install/index.php to pull in the code already existing to check the maximum memory (system_check_memory_limit).

Code

// Include system functions
include("../inc/tools/model/_system.funcs.php");

2. The code to check the memory and die if there isn't enough. I came up with 20M through trial-and-error on a 64bit Ubuntu system. The check and die() statement are modeled after the existing ones for MySQL and PHP version.

I put it immediately after the code to check the PHP version because it makes sense to check the version before the settings.

Code

// Check sufficient memory allocated in PHP
$MAX_MEMORY = system_check_memory_limit();
$REQUIRED_MEMORY = 20480;
$REQUIRED_MEMORY_FRIENDLY = "20M";
if ( $MAX_MEMORY < $REQUIRED_MEMORY )
{
    die ('<div class="error"><p class="error"><strong>' . sprintf(T_('The minimum PHP memory requirement for this version of b2evolution is %d (%s), but you only have %d!'), $REQUIRED_MEMORY, $REQUIRED_MEMORY_FRIENDLY, $MAX_MEMORY) . '</strong></p></div>');
}
10/18/10 @ 02:09

Comment from:

I tested the install script on v4.0.0 with 20M and it worked fine, so 30M would be ok.

That said, I didn't do full regression testing on every feature. I can go back and spot check some of the bigger things.

10/18/10 @ 21:08

Comment from:

I use 700M in my app to be able to convert huge PNG images into JPEG. It all depends on what you gonna do in your blog ;)

10/19/10 @ 02:24

Comment from:

Francois, I've sent you two messages via sourceforge with no response. If you give me CVS access then I'm happy to add this guardrail to the install script, but if I don't get access then there's not a whole lot I can do.

10/30/10 @ 05:40

Comment from:

Yes it definitely depends on what you're going to do. Image manipulation and plugins can consume a lot of RAM. But, nevertheless, there is a limit where we should warn users. I'm not sure what that limit is. It basically requires testing in live environments. I believe 32M should be enough for the vast majority of users.

11/02/10 @ 21:07

Comment from:

I had to increase memory via my .htaccess file to 256MB after I updated the server to php 5.xxx

The problem only occured with b2's file manager in a large file area.

01/14/11 @ 11:15
powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.