Bug #14037 Updated: Memory leak in xmldocfile function
ID: 14037
User updated by: mikep@oeone.com
Reported By: mikep@oeone.com
Old Status: Feedback
Status: Open
Bug Type: DOM XML related
Operating System: Linux
PHP Version: 4.0.6
New Comment:
Here's the explanation from mostafah@oeone.com (our resident C expert):
In the ext/domxml/php_domxml.c there is a destructor function named php_free_xml_doc(). In the loop
code that mikep@oeone.com has posted this destructor function gets invoked after the end of the loop
which for some reason won't free up memory. We thought maybe the xmldoc memory
should be released within the loop that is after getting an xmldoc object into $doc and before
overwriting it through the next iteration of the loop. So we added our own xmldocfree( $doc )
function and put it in the loop. We had no memory leak anymore but then we encountered segfaults in
the apache log file which of course was because of the native destructor being invoked on an already
released object. So maybe even our xmldocfree wasn't working properly and the segfault was
somehow cleaning up everything behind. But anyway we are happy now because the
memory leak is gone and the segfault does not effect our functionality.
Previous Comments:
------------------------------------------------------------------------
[2001-11-29 09:48:25] mfischer@php.net
By patching what? ext/domxml?
FYI, apache doesn't release memory it once grabs. Thats how it works.
Feedback.
------------------------------------------------------------------------
[2001-11-29 09:42:22] mikep@oeone.com
As stated, the memory used by Apache sky rockets... On my machine, it goes up to about 90% or so.
We're working on a patch to this bug, we've got the memory leak fixed by closing the file
using a function we wrote, but unfortunately that ended up causing a segfault in Apache.
When we fix that problem, we'll post the fix here.
------------------------------------------------------------------------
[2001-11-29 09:38:04] mfischer@php.net
What do you define as 'memory leak' ? Error output in apaches log?
Feedback.
------------------------------------------------------------------------
[2001-11-12 17:01:15] mikep@oeone.com
<?php
echo "starting test ...<p>";
flush();
for ($i=0; $i<100; $i++)
{
$doc = xmldocfile( "SOMEXMLFILE" );
}
echo "test finished";
?>
When this is done on Apache, the memory used by Apache sky rockets. The larger the XML file, the
larger the memory leak.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14037&edit=1
Thread (9 messages)