note 73407 added to ref.simplexml

From: Date: Wed, 21 Feb 2007 22:04:38 +0000
Subject: note 73407 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-123681@lists.php.net to get a copy of this message
Memory leak when setting attributes as in example (#Example 2134. Setting values) This probably goes unnoticed in web scripts (unless you do a LOT of xml manipulations), but I ran into this in my standalone script that processes a large number of XML files. The following code will eat up memory quite fast: <?php include 'example.php'; while (true) { $xml = new SimpleXMLElement($xmlstr); $xml->movie[0]->characters->character[0]->name = 'Miss Coder'; } ?> while this seems to behave correctly: <?php include 'example.php'; while (true) { $xml = new SimpleXMLElement($xmlstr); $c = $xml->xpath("//character"); $c[0]->name = 'Miss Coder'; } ?> This looks like bug #38604, and I just confirmed that in 6.0.0-dev (on Windows at least) it is fixed. It is NOT fixed in 5.2.1 or 5.2.2-dev (2/21 build), so for 5.2 users, use the second form to avoid leaks. ---- Server IP: 64.71.164.2 Probable Submitter: 208.64.184.194 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/73407 Del: integrated -- https://master.php.net/note/delete/73407/integrated Del: useless -- https://master.php.net/note/delete/73407/useless Del: bad code -- https://master.php.net/note/delete/73407/bad+code Del: spam -- https://master.php.net/note/delete/73407/spam Del: non-english -- https://master.php.net/note/delete/73407/non-english Del: in docs -- https://master.php.net/note/delete/73407/in+docs Del: other reasons-- https://master.php.net/note/delete/73407 Reject -- https://master.php.net/note/reject/73407 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123681) next »