Bug #62468 [NEW]: SimpleXML memory leak, if circular references are removed by Garbage Collector
| From: | zerkyn at gmail dot com | Date: | Mon, 02 Jul 2012 20:13:45 +0000 |
| Subject: | Bug #62468 [NEW]: SimpleXML memory leak, if circular references are removed by Garbage Collector | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-171700@lists.php.net to get a copy of this message | ||
From: zerkyn at gmail dot com
Operating system: Windows 7, Linux
PHP version: 5.3.14
Package: SimpleXML related
Bug Type: Bug
Bug description:SimpleXML memory leak, if circular references are removed by Garbage Collector
Description:
------------
The SimpleXMLElement memory leaks, when:
1) An object holds reference to a SimpleXMLElement, and
2) The object is involved in a circular references net, and
3) All external references to that net are cleared, so Garbage Collector
finds that net, correctly sees it as a garbage cycle, and cleans all its
objects
After the Garbage Collector finishes its work, the memory, consumed by
SimpleXMLElement is not freed, thus producing a memory leak.
The issue is reproduced both at Windows and Linux platforms.
Full version for the test script is there:
https://dl.dropbox.com/u/17950262/php/issues/simplexml_memory_leak.zip
Test script:
---------------
<?php
class SelfLinked
{
public $xml;
public $me;
public function __construct()
{
$this->xml =
simplexml_load_file('pretty_big_file_of_1mb_size.xml');
$this->me = $this;
}
}
echo "Sys memory usage before: ", SystemMemoryUsage(), "\n";
for ($i = 0; $i < 1000; $i++) {
$a = new SelfLinked();
unset($a);
gc_collect_cycles();
}
echo "Sys memory usage after: ", SystemMemoryUsage(), "\n";
/** ----------------------------------------------------- */
function SystemMemoryUsage()
{
...
// Return memory consumption by executing system tool - tasklist, ps or
anything else
// See https://bugs.php.net/bug.php?id=62467
on proper memory profiling
of SimpleXML functions
}
}
Expected result:
----------------
Memory consumption does not change.
Actual result:
--------------
Huge increase of memory consumption is reported.
--
Edit bug report at https://bugs.php.net/bug.php?id=62468&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62468&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62468&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62468&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62468&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62468&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62468&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62468&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62468&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62468&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62468&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62468&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62468&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62468&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62468&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62468&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62468&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62468&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62468&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62468&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62468&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62468&r=mysqlcfg