From:
Operating system: Mac OS X 10.6.7
PHP version: 5.3.6
Package: Performance problem
Bug Type: Bug
Bug description:Memory Leak in magic method __get() [Zend Memory Manager]
Description:
------------
For some reason values returned by __get() aren't released from memory.
$ php memory.php # (without --debug)
0.0096 seconds and 1.3461 MB for 10000 accessing known property
$ php memory.php # (with --debug)
0.0317 seconds and 2.6435 MB for 10000 accessing known property
$ export USE_ZEND_ALLOC=0
$ php memory.php # (with --debug)
0.0267 seconds and 0.0000 MB for 10000 accessing known property
since disabling Zend Memory Manager solved the issue, the valgrind log is
pretty much useless, thus not attached.
Test script:
---------------
<?php
class Memleak
{
public function __get($name)
{
return "hello world";
}
}
$iterations = 10000;
$foo = new Memleak();
$start = microtime(true);
$mem = memory_get_usage();
for ($i=0; $i < $iterations; $i++) {
$foo->{'bar' . $i};
}
$_mem = memory_get_usage();
$_start = microtime(true);
printf("%0.4f seconds and %0.4f MB for %d accessing known property\n",
$_start - $start, ($_mem - $mem) / 1024 / 1024, $iterations);
?>
Expected result:
----------------
0.0099 seconds and 0.0000 MB for 10000 accessing known property
Actual result:
--------------
0.0099 seconds and 1.3460 MB for 10000 accessing known property
--
Edit bug report at http://bugs.php.net/bug.php?id=55033&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=55033&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=55033&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=55033&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=55033&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=55033&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=55033&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=55033&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=55033&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=55033&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=55033&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=55033&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=55033&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=55033&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=55033&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=55033&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=55033&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=55033&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=55033&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=55033&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=55033&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=55033&r=mysqlcfg