#41220 [NEW]: serialize takes huge amount of memory

From: Date: Sat, 28 Apr 2007 22:30:41 +0000
Subject: #41220 [NEW]: serialize takes huge amount of memory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112032@lists.php.net to get a copy of this message
From: shshzi at gmail dot com Operating system: Linux i386 PHP version: 5.2.1 PHP Bug Type: Reproducible crash Bug description: serialize takes huge amount of memory Description: ------------ when using serialize on some large (not huge) array, it will take insane amounts of memory. look at the code , when using size array of 30,000 , the script works as expected, indicating that the output is a mere 2MB in length, while enlarging the array to 50,000 elements causes php to go crazy and hit the 600MB i've allowed him to consume... Reproduce code: --------------- <? $a = array(); for($i=0;$i<50000;$i++) { $a[$i] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; } $z = serialize($a); print strlen($z); ?> -- Edit bug report at http://bugs.php.net/?id=41220&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41220&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41220&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41220&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41220&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41220&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41220&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41220&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41220&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41220&r=support Expected behavior: http://bugs.php.net/fix.php?id=41220&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41220&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41220&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41220&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41220&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41220&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41220&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41220&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41220&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41220&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41220&r=mysqlcfg

« previous php.bugs (#112032) next »