|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-24 16:56 UTC] toggg@php.net
Description: ------------ It was originated by http://pear.php.net/bugs/bug.php?id=6788 Reproduce code: --------------- <?php class test { var $backtrace = null; function test() { $this->backtrace = debug_backtrace(); } } set_time_limit(0); for($i = 0; $i <= 10000; $i++) { $ret = &new test(); unset($ret); } ?> Expected result: ---------------- nothing Actual result: -------------- memory exhausted PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 11:00:01 2025 UTC |
This not the same situation as #33487 Here, it's not a question of local variable within a method. And we actually unset the created object. If I do the same with $this->backtrace = str_pad(' ', 2300); then the memory is not eaten up. This occurs only if debug_backtrace() result is affected to a property of the test object.OK, nice, that explains the difference to php4. unset($res) is not sufficient ... obviously, <?php class test { var $backtrace = null; function test() { $this->backtrace = debug_backtrace(); unset($this->backtrace[0]['object']); } } set_time_limit(0); for($i = 0; $i <= 500000; $i++) { $ret = &new test(); unset($ret); } ?> does not break anymore. However, this circular reference is due to the new 'object' returned by debug_backtrace() which is not documented. It merits a *big* warning. Also, it had been nice to be able to do it by __destruct() , but it's not called by unset() ... I report back to pear , thanks !