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.

Oct 5, 2010 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.

Oct 5, 2010 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.

Oct 5, 2010 15:17

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

Oct 10, 2010 20:10

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

Oct 10, 2010 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.

Oct 10, 2010 20:22

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

Oct 11, 2010 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.

Oct 17, 2010 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?

Oct 18, 2010 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).

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

Oct 18, 2010 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.

Oct 19, 2010 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 ;)

Oct 30, 2010 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.

Nov 2, 2010 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.

Jan 14, 2011 11:15

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.


Form is loading...

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