From:             mike at netagi dot com
Operating system: Ubuntu Linux 6.06 LTS
PHP version:      4.4.7
PHP Bug Type:     DOM XML related
Bug description:  possible memory leak in DomNode->first_child

Description:
------------
Directly after calling node->first_child the memory usage increases and
does not drop. This might also be the case with has_child_nodes.

I've tried numerous test cases (as I am trying to keep memory consumption
low) but have had no luck. I've tried using functions so the variables lose
scope etc. Whatever gets created during the first_child can never be
freed.

I understand that the Zend Engine may be caching some structures, however
i have allocated 120 Meg to PHP4 CLI and it's still returning an out of
memory error. If I disable first_child the script runs without any issues.



Reproduce code:
---------------
$doc = domxml_open_file("import_prod_cat.xml");
$xpath = $doc->xpath_new_context();
$obj = $xpath->xpath_eval('//import_catprod_link');
$nodeset = $obj->nodeset;
foreach($nodeset as $node ) {
        print "S1 " . memory_get_usage() . "\n";
        if( $node->has_child_nodes() ) {
                print " S2 " . memory_get_usage() . "\n";
                $child = $node->first_child();
                print " S3 " . memory_get_usage() . "\n";
                unset($child);
                unset($node);
                print " S4 " . memory_get_usage() . "\n";
        }
        print " S6 " . memory_get_usage() . "\n";
}
$doc->free();

Actual result:
--------------
S1 21202968
 S2 21203040
 S3 21204416
 S4 21204456
 S5 21204456

S1 21204456
 S2 21204456
 S3 21205184
 S4 21205224
 S5 21205224

S1 21205224
 S2 21205224
 S3 21205952
 S4 21205992
 S5 21205992

S1 21205992
 S2 21205992
 S3 21206720
 S4 21206760
 S5 21206760

... etc until it runs out of ram.

-- 
Edit bug report at http://bugs.php.net/?id=41452&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41452&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41452&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41452&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41452&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41452&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41452&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41452&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41452&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41452&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41452&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41452&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41452&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41452&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41452&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41452&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41452&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41452&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41452&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41452&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41452&r=mysqlcfg

Reply via email to