#31297 [Opn->Bgs]: object instantiation/destruction memory leak
ID: 31297
Updated by: derick@php.net
Reported By: kris dot public at kauper dot net
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: Fedora Core 2
PHP Version: 5CVS-2004-12-26 (dev)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The Zend Engine internally caches some structures for later use, so
it's perfectly normal that you see this behavior.
Previous Comments:
------------------------------------------------------------------------
[2004-12-26 02:48:42] kris dot public at kauper dot net
Description:
------------
While trying to track down a memory leak in my app, I came across this
behaviour:
Instantiating an object of a class that contains 9 or more class
variables, and then destroying that object, leaves 64 bytes of
unreclaimed memory.
Performing the same test with a class that contains 8 or fewer class
variables does not result in the same memory leak.
I've tried the supplied test script with PHP 4.3.8/9/10 and the latest
CVS version of PHP5, with the same results for each. In each case, I
compiled PHP using:
./configure --enable-memory-limit
Reproduce code:
---------------
<?php
// simple class having 9 class variables
class ClassWith9Vars
{
var $a1 = NULL;
var $a2 = NULL;
var $a3 = NULL;
var $a4 = NULL;
var $a5 = NULL;
var $a6 = NULL;
var $a7 = NULL;
var $a8 = NULL;
var $a9 = NULL;
}
// simple class having 8 class variables
class ClassWith8Vars
{
var $a1 = NULL;
var $a2 = NULL;
var $a3 = NULL;
var $a4 = NULL;
var $a5 = NULL;
var $a6 = NULL;
var $a7 = NULL;
var $a8 = NULL;
}
echo ("Starting test using ClassWith9Vars\n");
$m1 = memory_get_usage();
for ($i = 0; $i < 10; $i++)
{
$test =& new ClassWith9Vars();
unset($test);
$m2 = memory_get_usage();
echo ("leak = " . ($m2 - $m1) . "\n");
$m1 = $m2;
}
echo ("Starting test using ClassWith8Vars\n");
$m1 = memory_get_usage();
for ($i = 0; $i < 10; $i++)
{
$test =& new ClassWith8Vars();
unset($test);
$m2 = memory_get_usage();
echo ("leak = " . ($m2 - $m1) . "\n");
$m1 = $m2;
}
?>
Expected result:
----------------
Starting test using ClassWith9Vars
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
Starting test using ClassWith8Vars
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
Actual result:
--------------
Starting test using ClassWith9Vars
leak = 608
leak = 88
leak = 64
leak = 64
leak = 64
leak = 64
leak = 64
leak = 64
leak = 64
leak = 64
Starting test using ClassWith8Vars
leak = 32
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
leak = 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31297&edit=1
Thread (2 messages)