From: slaporte at eurocortex dot fr
Operating system: red hat
PHP version: 4.3.9
PHP Bug Type: DOM XML related
Bug description: DOM XML Extension xpath_new_context memory leak
Description:
------------
Hello
i'm using php and dom xml
i encounter a memory leak
the destructor of xpath context
is not called
i'm using 4_3_9 version
i put some fprintf(stderr, ...) into the destructor
and it never go inside
the destructor was registered with "xpathcontext"
le_xpathctxp = zend_register_list_destructors_ex(php_free_xpath_context,
NULL, "xpathcontext", module_number);
the class with "XPathContext"
INIT_OVERLOADED_CLASS_ENTRY(ce, "XPathContext",
php_xpathctx_class_functions, NULL, NULL, NULL);
i try to make both lowercase
but it is changing nothing
the test script is very simple
and when you run it
and the process grow and grow and grow ....
i add a function free to xpathcontext object
that function calls the destructor
then the memory is released
but i would prefer that the destructor be called naturally
Reproduce code:
---------------
function StringToXml($sXml) {
$oDom = domxml_open_mem($sXml);
$oCtx = $oDom->xpath_new_context();
unset($oCtx);
$oDom->free();
unset($oDom);
}
$s = getFile("test.xml");
for($n=200000; $n--;) {
echo "$n<br/>";
flush();
StringToXml($s);
}
Expected result:
----------------
php process should not grow, memory should be released
Actual result:
--------------
php process grow
--
Edit bug report at http://bugs.php.net/?id=30911&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30911&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=30911&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=30911&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30911&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30911&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30911&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30911&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30911&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30911&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30911&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=30911&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=30911&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30911&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30911&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30911&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30911&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30911&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30911&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30911&r=mysqlcfg