|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-10-09 18:02 UTC] johannes@php.net
-Status: Open
+Status: Bogus
[2010-10-09 18:02 UTC] johannes@php.net
[2010-10-09 18:20 UTC] an0nym at narod dot ru
-Type: Bug
+Type: Feature/Change Request
[2010-10-09 18:20 UTC] an0nym at narod dot ru
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 23:00:02 2025 UTC |
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)