php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53454 Memory leak when using non-static class member as static one or inversely
Submitted: 2010-12-02 19:36 UTC Modified: 2010-12-03 22:35 UTC
From: hritter at e-onsoftware dot com Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.2.14 OS: Linux gentoo
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hritter at e-onsoftware dot com
New email:
PHP Version: OS:

 

 [2010-12-02 19:36 UTC] hritter at e-onsoftware dot com
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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-02 19:55 UTC] hritter at e-onsoftware dot com
-Status: Open +Status: Closed
 [2010-12-02 19:55 UTC] hritter at e-onsoftware dot com
I am really confused, the leak was due to the PHP debugger I implemented. (No leak when test the bug without this debugger)
 [2010-12-03 22:35 UTC] cataphract@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC