Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64102 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95105 invoked from network); 29 Nov 2012 13:36:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2012 13:36:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=scope@planetavent.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=scope@planetavent.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain planetavent.de from 89.107.189.172 cause and error) X-PHP-List-Original-Sender: scope@planetavent.de X-Host-Fingerprint: 89.107.189.172 mail.xa8.serverdomain.org Linux 2.6 Received: from [89.107.189.172] ([89.107.189.172:39982] helo=mail.xa8.serverdomain.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/D2-08727-5E467B05 for ; Thu, 29 Nov 2012 08:36:38 -0500 Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) (Authenticated sender: xa8190p1) by mail.xa8.serverdomain.org (mail.xa8.serverdomain.org) with ESMTPSA id E4F6028138178 for ; Thu, 29 Nov 2012 14:36:33 +0100 (CET) Received: by mail-we0-f170.google.com with SMTP id r1so3759913wey.29 for ; Thu, 29 Nov 2012 05:36:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.86.7 with SMTP id l7mr35201074wiz.5.1354196192290; Thu, 29 Nov 2012 05:36:32 -0800 (PST) Received: by 10.227.38.212 with HTTP; Thu, 29 Nov 2012 05:36:32 -0800 (PST) Date: Thu, 29 Nov 2012 14:36:32 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d04428e02ff697c04cfa25ea0 Subject: DOMNodeList memory eating From: scope@planetavent.de (Nicolai Scheer) --f46d04428e02ff697c04cfa25ea0 Content-Type: text/plain; charset=UTF-8 Hi! Just stumbled upon a strange behaviour when iterating over DOMNodeLists. Before I open a bug report I'd like to ask if anyone can comment on this issue, maybe it's the excpected behaviour. Consider the following small script: x x x XML; $dom = new DOMDocument(); $dom->loadXML( $xml ); $xpath = new DOMXPath( $dom ); while ( true ) { # 1. memory eater... $link_object_list = $xpath->query( '//node' ); # 2. constant memory usage #$link_object_list = $dom->getElementsByTagName( 'node' ); foreach ( $link_object_list as $value ) { while ( true ) { $link = $link_object_list->item( 0 ); } } } ?> Strange thing is, if the DomNodeList is produced by the xpath query, the script eats memory. If I use getElementsByTagName to get the list memory usage is constant. $value holds the object handle for the first NodeItem. If another list element is accessed (e.g. the second one) the usage is constant as well (both cases). Seems as if there's something strange going on with object handles and / or wrong garbage collection. Or maybe I'm just confusing things here ;) Any comments? Greetings Nico --f46d04428e02ff697c04cfa25ea0--