From: lorenzo dot reffo at gmail dot com
Operating system: Linux Ubuntu
PHP version: 5.2.6
PHP Bug Type: Class/Object related
Bug description: memory leak when reassigning object
Description:
------------
I encountered an error while assigning multiple class to an object into
another class.
Suppose to have a class A in which is defined a property. At the begin, I
use the property as an instance of another class B, then I do an 'unset' of
property before creating assigning it an instance of class C.
Reproduce code:
---------------
class B {
# do something
}
class C {
# do something
}
class A {
private $_prop;
function __construct() {
$this->_prop = new B();
}
function Re () {
unset($this->_prop);
$this->_prop = new C();
}
}
$h = new A()
$h->Re();
unset($h);
Expected result:
----------------
I expect it to work correctly (I read a post before where staff said it
has been fixed in version 5.2.x).
Actual result:
--------------
it crashes when calling 'Re' method giving me an error:
Allowed memory size of ... bytes exhausted etc.
--
Edit bug report at http://bugs.php.net/?id=46126&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46126&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46126&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46126&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46126&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=46126&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46126&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46126&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46126&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46126&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46126&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46126&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46126&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46126&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46126&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46126&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46126&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46126&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46126&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46126&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46126&r=mysqlcfg