Bug #52497 [NEW]: Memory Leak in classes cycle reference
| From: | tecnico at adam-italia dot it | Date: | Fri, 30 Jul 2010 07:53:24 +0000 |
| Subject: | Bug #52497 [NEW]: Memory Leak in classes cycle reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-152967@lists.php.net to get a copy of this message | ||
From:
Operating system: CentsOS
PHP version: 5.2.14
Package: *General Issues
Bug Type: Bug
Bug description:Memory Leak in classes cycle reference
Description:
------------
Memory Leak in classes cycle reference
Test script:
---------------
class foo {
protected $mBar=null;
public function setBar(bar $value){
$this->mBar=$value;
}
public function __destruct(){
unset($this->mBar);
}
}
class bar {
protected $mFoo=null;
protected $mContent=null;
public function __construct() {
$this->mContent=str_repeat("prova",10000);
}
public function setFoo(foo $value){
$this->mFoo=$value;
}
public function __destruct(){
unset($this->mFoo);
}
}
ini_set("memory_limit","32M");
$cont=0;
while($cont<1000){
$cont++;
$tmp_foo=new Foo();
$tmp_bar= new Bar();
$tmp_foo->setBar($tmp_bar);
$tmp_bar->setFoo($tmp_foo);
unset($tmp_foo, $tmp_bar);
}
Expected result:
----------------
no mem leak
Actual result:
--------------
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to
allocate 50001 bytes)
--
Edit bug report at http://bugs.php.net/bug.php?id=52497&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52497&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52497&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52497&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52497&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52497&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52497&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52497&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52497&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52497&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52497&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52497&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52497&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52497&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52497&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52497&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52497&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52497&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52497&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52497&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52497&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52497&r=mysqlcfg