#17 Memory Exhasted Bug Fix Suggestion

2.2
closed-fixed
nobody
None
5
2011-09-18
2007-08-14
No

From Help Forum:

RE: allowed memory Size exhausted (New)
By: Jeff Walters (jeffjw) - 2007-08-14 17:20

I'm hitting a similar problem trying to backup a large SugarCRM MySQL database. I can tweak the memory settings for PHP and get things to run a bit longer, but eventually I run out of memory and things fail. I'm running the backup.php script in shell mode, using a cron job.

Here's the error:

[root@crm phpMyBackupPro]# cd /srv/www/html/phpMyBackupPro; php -f backup.php fonon_crm 1 1
+======>
| phpMyBackupPro v.2.1 (c) 2004-2007 by Dirk Randhahn
| http://www.phpMyBackupPro.net
+======>
Allowed memory size of 134217728 bytes exhausted (tried to allocate 144 bytes)

The backup works just fine without the data; just the table structure. It always fails with the table data.

BTW, I love this project!
Jeff Walters

RE: allowed memory Size exhausted (New)
By: Jeff Walters (jeffjw) - 2007-08-14 18:21
Temporary solution and/or bug fix request.

Interesting enough, I got the backup to work fully through my 500+MB MySQL database by adjusting the $max_size in the PMBP_dump function; see functions.inc.php file. Note the two "/2" additions.

Change:
// set max string size before writing to file
if (@ini_get("memory_limit")) $max_size=900000*ini_get("memory_limit");
else $max_size=$PMBP_SYS_VAR['memory_limit'];

To:
// set max string size before writing to file
if (@ini_get("memory_limit")) $max_size=900000*ini_get("memory_limit")/2;
else $max_size=$PMBP_SYS_VAR['memory_limit']/2;

The bug/problem is in the export data routine. The script needs to write the data to the export file before it gets to $max_size, not after it exceeds $max_size. If two rows of data from one table exceed the $max_size then the script will fail. In other words, you can't decide to write the data after you've already run out of memory. You must write the data before you run out of memory. It seems silly to just divide the memory limit by 2 (50%), but it works for me. You might be able to use 70% or even 90% of the memory_limit. It depends on the data.

Cheers,
Jeff Walters
JJW Design

Discussion

  • Dirk

    Dirk - 2008-01-10
    • status: open --> open-accepted
     
  • Dirk

    Dirk - 2011-09-18
    • milestone: --> 2.2
    • status: open-accepted --> open-fixed
     
  • Dirk

    Dirk - 2011-09-18
    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks