From: joe at estara dot com Operating system: Linux PHP version: 5.1.4 PHP Bug Type: Apache2 related Bug description: Use 'unserialize', then a large amount of memory is not returned to the OS
Description: ------------ If you use unserialize on a large multidimensional array, each apache process it runs in ends up taking up over 68m of ram (the actual size depends on your array that you're unserializing) This is actual ram (Resident minus shared ram), and doesn't return it to the operating system after the script exits. Since you have say MaxClients in apache2 of 150, 150 times 68m of ram means swapping to death. This is using prefork. Reproduce code: --------------- <?php ini_set("memory_limit", "64M"); # ziplatlong is an array, with zip code as a key and a 2 element lat long array as the value $s = file_get_contents("ziplatlong"); $zip = unserialize($s); preg_match("/foo/", $zip["00601"][0]); Expected result: ---------------- I'd expect most of the ram returned to the operating system. When I do something similar, use the same levels of ram, apache only takes up ~10M of ram, even though it uses ~64M while processing. <?php ini_set("memory_limit", "64M"); for($i=0;$i<50; $i++) $s[$i] = file_get_contents("ziplatlong"); preg_match("/foo/", $s[38]); Actual result: -------------- Machine swaps to death. -- Edit bug report at http://bugs.php.net/?id=37929&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37929&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37929&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37929&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37929&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37929&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37929&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37929&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37929&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37929&r=support Expected behavior: http://bugs.php.net/fix.php?id=37929&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37929&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37929&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37929&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37929&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37929&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37929&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37929&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37929&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37929&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37929&r=mysqlcfg