ID: 16335 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: linux PHP Version: 4.1.1 New Comment:
Please do not submit the same bug more than once. Previous Comments: ------------------------------------------------------------------------ [2002-03-28 17:02:34] [EMAIL PROTECTED] I found a serious memory leaks which occures when passing objects. I have included two small code snipplets which will reproduce the leak: Code Snipplet-1: memory leak when passing $this object. <?php class Tok { var $_filter = array(); function filter($name, &$obj) { $this->_filter[$name] =& $obj; } } class A { var $_tok; function A() { $this->_tok = new Tok(); $this->_tok->filter('xyz', $this); // memory leak } } $a = new A(); ?> Leak message in error.log: zend_hash.c(260) : Freeing 0x08210544 (39 bytes), script=/home/share/server/test/index2.php Last leak repeated 2 times zend_hash.c(176) : Freeing 0x082104F4 (32 bytes), script=/home/share/server/test/index2.php Last leak repeated 2 times ./zend_execute.c(753) : Freeing 0x08210494 (44 bytes), script=/home/share/server/test/index2.php zend_variables.c(117) : Actual location (location was relayed) Last leak repeated 1 time zend_API.c(593) : Freeing 0x0821019C (44 bytes), script=/home/share/server/test/index2.php zend_API.c(581) : Actual location (location was relayed) Last leak repeated 1 time ./zend_execute.c(1940) : Freeing 0x0820E714 (12 bytes), script=/home/share/server/test/index2.php Last leak repeated 1 time Here an another example (i think related): Code-Snipplet-2: <?php class A { var $_parent; function setParent(&$obj) { $this->_parent =& $obj; } function setParentCopy($obj) { $this->_parent = $obj; } } $a1 = new A(); $a2 = new A(); $a1->setParent($a2); // works $a1->setParent($a1); // memory leak $a1->setParentCopy($a1); // memory leak too echo "done"; ?> Leak message in error.log: zend_hash.c(260) : Freeing 0x085698BC (43 bytes), script=/home/share/server/test/index.php zend_hash.c(176) : Freeing 0x0856986C (32 bytes), script=/home/share/server/test/index.php ./zend_execute.c(425) : Freeing 0x0856980C (44 bytes), script=/home/share/server/test/index.php zend_variables.c(126) : Actual location (location was relayed) ./zend_execute.c(1940) : Freeing 0x08368BCC (12 bytes), script=/home/share/server/test/index.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16335&edit=1