Ask a Question related to PHP Bugs, Design and Development.
-
taneli at crasman dot fi #1
#39328 [NEW]: Memory leak when object contains reference to "parent" object
From: taneli at crasman dot fi
Operating system: Linux
PHP version: 5.1.6
PHP Bug Type: Scripting Engine problem
Bug description: Memory leak when object contains reference to "parent" object
Description:
------------
The example says it the best. Reproducible in both 5.1.6 and 4.4.4 (with
minor changes), all extensions disabled. Definately related to references,
although I'm not sure if the code below is good practice, but I've run into
it on more than one occasion. I think it should be freeing the objects when
they go out of scope, but the reference counting must be broken somehow.
Might be related to #22055, but this one's been around for ages.
Reproduce code:
---------------
<?php {
class A {
var $ba;
function A() {
$this->ba = array();
for ($i = 0; $i < 100; $i++)
$this->ba[] = new B($this);
}
function __destruct() { // never gets called
die("Freeing class A\n");
}
}
class B {
var $a;
function B($a) { // function B(&$a), and:
$this->a = $a; // $this->a =& $a; leaks in php 4.4.4
// remove line above to prevent leak
}
function __destruct() { // never gets called either
die("Freeing class B\n");
}
}
$smu = memory_get_usage();
while (true) {
$ba = array();
for ($i = 0; $i < 100; $i++)
$ba[] = new A();
$emu = memory_get_usage();
echo sprintf("leak %.1f kB\r", ($emu - $smu) / 1024.0);
}
}?>
Expected result:
----------------
No memory leak.
Actual result:
--------------
Rapidly increasing memory leak.
--
Edit bug report at [url]http://bugs.php.net/?id=39328&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39328&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39328&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39328&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39328&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=39328&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=39328&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39328&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=39328&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=39328&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=39328&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=39328&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=39328&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=39328&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39328&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=39328&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=39328&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39328&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=39328&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39328&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39328&r=mysqlcfg[/url]
taneli at crasman dot fi Guest
-
#39328 [Bgs]: Memory leak when object contains reference to "parent" object
ID: 39328 User updated by: taneli at crasman dot fi Reported By: taneli at crasman dot fi Status: Bogus Bug Type: ... -
#39328 [Opn->Bgs]: Memory leak when object contains reference to "parent" object
ID: 39328 Updated by: derick@php.net Reported By: taneli at crasman dot fi -Status: Open +Status: ... -
"Object reference not set" when loading a textbox in a user control
Hi All, I have a user control that shows name and address for a person in a text box. When the page hosting the control loads up, it calls a... -
"object reference not set to an instance of an object" w/ unmanaged DLL call.
Hello, I have an ASP.Net 1.1 web service running on a Win2K Server machine under IIS 5.0. Within the web service project, I have a class whose... -
"Object reference not set to an instance of an object" error
Hi. Using ASP.NET, getting an "Object reference not set to an instance of an object" error. In my login.aspx page I have: string...



Reply With Quote

