|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-03-25 02:01 UTC] sniper@php.net
[2005-04-02 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 16:00:01 2025 UTC |
Description: ------------ See reproducible code below Reproduce code: --------------- <? /** cross-referencing memory leak. PHP garbage collector doesn't free memory for cross-referencing objects. It could be great problem for daemons or services, written on PHP */ function memleak($size) { $a = str_repeat('a', $size); // construct child $child = array( 'data' => $a, ); // construct parent $parent = array( 'data' => $a, 'child' => &$child, ); // comment following line to prevent memleak $child['parent'] = &$parent; } // try to leak of 1GB memory for ($i = 0; $i < 1000; $i++) memleak(1000000); sleep(10); ?> Expected result: ---------------- normal execution of script Actual result: -------------- PHP occupies all available memory.