We were having trouble with memory usage.. finally only 700mb of memory for php would fix it. Yikes!

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 785555 bytes) in /srv/www/vhosts/hockeystars.randomlink.com/httpdocs/sites/all/modules/amfphp/amfphp.module on line 90

It seems the issue is with the call to the serialize function, apparently when used with a complex array like what can often happen with this module, serialize uses a ridiculous amount of memory.

Discovered this article: http://bugs.php.net/bug.php?id=39736

When we replaced the call to serialize with a new version of the function defined in the article memory usage is minimal again.

function my_serialize( &$data, $buf = "" )
{
if( is_array( &$data ))
{
$buf .= "a:" . count( &$data ) . ":{";
foreach( $data as $key => &$value )
{
$buf .= serialize( $key ) . my_serialize( &$value );
}
$buf .= "}";
return $buf;
}
else
{
return $buf . serialize( &$data );
}
}

Comments

snelson’s picture

Status: Active » Fixed

Good find, I've committed this to both the D5 and D6 branches.

- Scott

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.