Recent Topics

php5 defaults don't have enough memory

started by on 2010 Oct 04 – Last touched: 2010 Oct 04

2010 Oct 04 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.

2010 Oct 05 04:47

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.

2010 Oct 05 13:50

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.

2010 Oct 05 15:17

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

2010 Oct 10 20:10

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

2010 Oct 10 20:12

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.

2010 Oct 10 20:22

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

2010 Oct 11 01:55

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.

2010 Oct 17 23:23

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?

2010 Oct 18 02:09

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).


// Include system functions

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.


// Check sufficient memory allocated in PHP
$MAX_MEMORY = system_check_memory_limit();
    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>');

2010 Oct 18 21:08

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.

2010 Oct 19 02:24

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 ;)

2010 Oct 30 05:40

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.

2010 Nov 02 21:07

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.

2011 Jan 14 11:15

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

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

Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.