Bug->Req #53031 [Bgs]: GC does not collect before PHP issue "Allowed memory size exhausted"

From: Date: Sat, 09 Oct 2010 16:20:45 +0000
Subject: Bug->Req #53031 [Bgs]: GC does not collect before PHP issue "Allowed memory size exhausted"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155050@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53031&edit=1 ID: 53031 User updated by: an0nym at narod dot ru Reported by: an0nym at narod dot ru Summary: GC does not collect before PHP issue "Allowed memory size exhausted" Status: Bogus -Type: Bug +Type: Feature/Change Request Package: *General Issues Operating System: Windows Server 2008 R2 x64 PHP Version: 5.3.3 Block user comment: N New Comment: PHP can reuse memory, but doesn't do this. If this isn't a bug (that I'm not agree with), then this is surely a feature request. Previous Comments: ------------------------------------------------------------------------ [2010-10-09 18:02:19] johannes@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#155050) next »