From: benoit dot heinrich at swisscom dot com
Operating system: linux
PHP version: 4.4.7
PHP Bug Type: Unknown/Other Function
Bug description: memory leak in class method calls
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 bug report at http://bugs.php.net/?id=42758&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42758&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42758&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42758&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42758&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42758&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42758&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42758&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42758&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42758&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42758&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42758&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42758&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42758&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42758&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42758&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42758&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42758&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42758&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42758&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42758&r=mysqlcfg