ID: 42758
User updated by: benoit dot heinrich at swisscom dot com
Reported By: benoit dot heinrich at swisscom dot com
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: linux
PHP Version: 4.4.7
New Comment:
Sorry,
This was not a bug of PHP but a bug of the APD extension.
By disabling the APD extension the bug disappeared.
Cheers,
/Benoit
Previous Comments:
------------------------------------------------------------------------
[2007-09-26 09:18:16] benoit dot heinrich at swisscom dot com
Hi again,
I made some research to try to find out what is the exact reason of the
memory leak.
So I first try to replace the set method by a very simple method that
does nothing:
class ClassA
{
function method()
{
}
}
Then I tried to remove the 'for' loop and I created a test case with
10000 call to $obj->method(); and again I got the memory leak.
So my 2 cents that is a bug in the PHP engine call stack where it keeps
a pointer somewhere to the object that is calling the method.
Hope it helps.
/Benoit
------------------------------------------------------------------------
[2007-09-25 14:09:33] benoit dot heinrich at swisscom dot com
Description:
------------
Hi,
There is a memory leak when calling a method of a class.
I know the bug is fixed in PHP5 but for business reasons we can't
afford to upgrade to php5 right now.
Is that possible to fix this very annoying issue?
/Benoit
Reproduce code:
---------------
<?php
class ClassA
{
var $member;
function setMember($value)
{
$this->member = $value;
}
}
$obj =& new ClassA();
$mem = memory_get_usage();
for ($i=0; $i< 1000000; $i++)
$obj->member = null;
print "Direct property set memory leak is " .
number_format(memory_get_usage()-$mem) . "\n";
$mem = memory_get_usage();
for ($i=0; $i< 1000000; $i++)
$obj->setMember(null);
print "Method call memory leak is " .
number_format(memory_get_usage()-$mem) . "\n";
?>
Expected result:
----------------
Direct property set memory leak is 0
Method call memory leak is 0
Actual result:
--------------
Direct property set memory leak is 128
Method call memory leak is 8,000,040
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42758&edit=1