Bug #53031 [NEW]: GC does not collect before PHP issue "Allowed memory size exhausted"

From: Date: Sat, 09 Oct 2010 14:50:05 +0000
Subject: Bug #53031 [NEW]: GC does not collect before PHP issue "Allowed memory size exhausted"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155048@lists.php.net to get a copy of this message
From: Operating system: Windows Server 2008 R2 x64 PHP version: 5.3.3 Package: *General Issues Bug Type: Bug Bug description:GC does not collect before PHP issue "Allowed memory size exhausted" Description: ------------ GC does not collect cycles before PHP issue "Allowed memory size exhausted", therefore it is possible for a script to get this error even if GC is enabled and there is enough memory to reuse. To get error the script just has to fill all the remaining memory after last GC and before next, fill no matter how: with garbage or normal info. It is obvious for me, that calling GC before issuing error is a must have, as a last possibility to continue normal execution. Test script: --------------- <?php set_time_limit(0); error_reporting(PHP_INT_MAX); ini_set("memory_limit", "2M"); echo memory_get_peak_usage(true), "\r\n"; $o1 = new StdClass(); $o2 = new StdClass(); $o1->v1 = $o2; $o1->v2 = $o1; $o1->v = str_repeat("a", 1024 * 1024); unset($o1, $o2); echo memory_get_peak_usage(true), "\r\n"; $o1 = new StdClass(); $o2 = new StdClass(); $o1->v1 = $o2; $o1->v2 = $o1; $o1->v = str_repeat("a", 1024 * 1024); unset($o1, $o2); echo memory_get_peak_usage(true), "\r\n"; Expected result: ---------------- I expect to see the same result as if I run <?php ... echo memory_get_peak_usage(true), "\r\n"; $o1 = new StdClass(); $o2 = new StdClass(); $o1->v1 = $o2; $o1->v2 = $o1; gc_collect_cycles(); $o1->v = str_repeat("a", 1024 * 1024); unset($o1, $o2); echo memory_get_peak_usage(true), "\r\n"; Actual result: -------------- PHP Fatal error: Allowed memory size of * bytes exhausted (tried to allocate * bytes) -- Edit bug report at http://bugs.php.net/bug.php?id=53031&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53031&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53031&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53031&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53031&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53031&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53031&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53031&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53031&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53031&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53031&r=support Expected behavior: http://bugs.php.net/fix.php?id=53031&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53031&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53031&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53031&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53031&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53031&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53031&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53031&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53031&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53031&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53031&r=mysqlcfg

« previous php.bugs (#155048) next »