|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-06-12 14:14 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 00:00:02 2025 UTC |
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.