Bug #53454 [NEW]: Memory leak when using non-static class member as static one or inversely
| From: | hritter at e-onsoftware dot com | Date: | Thu, 02 Dec 2010 18:36:51 +0000 |
| Subject: | Bug #53454 [NEW]: Memory leak when using non-static class member as static one or inversely | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-156697@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux gentoo
PHP version: 5.2.14
Package: Performance problem
Bug Type: Bug
Bug description:Memory leak when using non-static class member as static one or inversely
Description:
------------
I had some memory overflow errors. I logged the memory usage step by step
and then I see a difference of 50Mo between two logs.
In the method called between this two logs, I used a static class attribute
as a non-static one (with $this). The modification on the attribute took
effect but triggered an "Interoperability or Compatibility Notice".
I fixed this error and I had a gain of 50 Mo!!
I have the same bug with a non-static method used as a static method (with
self::). I had a gain of 90Mo because this method was really far away in
the code.
It is a pretty harsh punishment for a compatibility error ;-)
Test script:
---------------
class LeakTester
{
private static $nTest = 0;
public function Test()
{
$this->nTest++;
echo $this->nTest."<br/>\n";
}
}
// ---> Test
$oTest = new LeakTester();
$oTest->Test();
echo memory_get_usage()."<br/>\n"; // (1)
$oTest->Test();
echo memory_get_usage()."<br/>\n"; // (2) > (1)
Expected result:
----------------
(2) should be equal to (1)
Actual result:
--------------
(2) is really greater than (1)
--
Edit bug report at http://bugs.php.net/bug.php?id=53454&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53454&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53454&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53454&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53454&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53454&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53454&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53454&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53454&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53454&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53454&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53454&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53454&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53454&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53454&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53454&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53454&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53454&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53454&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53454&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53454&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53454&r=mysqlcfg