note 59272 added to language.oop5.decon

From: Date: Thu, 01 Dec 2005 10:20:51 +0000
Subject: note 59272 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-99410@lists.php.net to get a copy of this message
For those who aren't already aware, PHP5 currently suffers from the classic reference counting leak. See http://en.wikipedia.org/wiki/Reference_counting for more info. Example code: <?php class Noisy { private $name; public function __construct($name) { $this->name = $name; echo "Noisy::__construct($this->name)\n"; } public function __destruct() { echo "Noisy::__destruct($this->name)\n"; } } function foo($num) { $noisy = new Noisy($num); //$noisy->me = $noisy; // Uncomment this line to create a cyclic reference } for ($i = 0; $i < 10; ++$i) foo($i); ?> As it stands, the destructor of class 'Noisy' will be called on '$noisy' when it goes out of scope in function 'foo', but uncommenting the second line in function 'foo' will prevent this, and cause a memory leak. See http://bugs.php.net/bug.php?id=33595 for a bug report, which reads as if this is not likely to get fixed in the near future, so watch out! ---- Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59272 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59272&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59272&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99410) next »