Edit report at http://bugs.php.net/bug.php?id=53031&edit=1
ID: 53031 Updated by: [email protected] Reported by: an0nym at narod dot ru Summary: GC does not collect before PHP issue "Allowed memory size exhausted" -Status: Open +Status: Bogus Type: Bug Package: *General Issues Operating System: Windows Server 2008 R2 x64 PHP Version: 5.3.3 Block user comment: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Check the documentation which describes when cycles are collected: http://de3.php.net/manual/en/features.gc.collecting-cycles.php This won't change. Previous Comments: ------------------------------------------------------------------------ [2010-10-09 16:50:04] an0nym at narod dot ru 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 this bug report at http://bugs.php.net/bug.php?id=53031&edit=1
