#46126 [Com]: memory leak when reassigning object
ID: 46126
Comment by: lorenzo dot reffo at gmail dot com
Reported By: lorenzo dot reffo at gmail dot com
Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Linux Ubuntu
PHP Version: 5.2.6
New Comment:
Thank you Felipe for your quick answer, unfortunately I haven't the
rights to use CVS on this server... anyway, in case anyone will
encounter the same problem I report a "temporary" solution I found:
error is raised only when using the unset function, while it will work
correctly simply setting a NULL value for property. So you just have to
replace a line such as
if(isset($_propertyname)) unset($_propertyname);
with a line like
$_propertyname = NULL;
I use version 5.2.4-2 of PHP (on ubuntu), hope this post will be useful
Previous Comments:
------------------------------------------------------------------------
[2008-09-19 15:51:36] felipe@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
------------------------------------------------------------------------
[2008-09-19 15:37:44] lorenzo dot reffo at gmail dot com
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 this bug report at http://bugs.php.net/?id=46126&edit=1
Thread (4 messages)