|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2018-09-12 16:01 UTC] ksours at internetbrands dot com
 Description: ------------ There is a note on the xml_set_object that you need to unset the xml resource variable to avoid memory leaks. This *really* needs to be more prominent. It's possible to hit this condition in code that does not call xml_set_object and that's not the obvious place to look for information on why xml_parser_free isn't working correctly. Recommend at a minimum that a similar not be placed on the xml_parser_free entry. (Ideally calling xml_parser_free *should* be sufficient to avoid holding that memory in place but I assume there is some reason why this is not feasible). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 18:00:01 2025 UTC | 
Poked this a little farther and determined there is some more nuance than I originally understood. Here is the code to reproduce my case (can't seem to update the script field via the edit interface) <?php class c { private $xml; private $test; public function test() { $this->xml = xml_parser_create(); xml_set_character_data_handler($this->xml, array(&$this, 'handle_cdata')); xml_parser_free($this->xml); $this->test = str_repeat('xxxxx', 1000000); } public function test2() { $xml = xml_parser_create(); xml_set_character_data_handler($xml, array(&$this, 'handle_cdata')); xml_parser_free($xml); $this->test = str_repeat('xxxxx', 1000000); } public function test3() { $this->xml = xml_parser_create(); xml_set_character_data_handler($this->xml, array(&$this, 'handle_cdata')); xml_set_character_data_handler($this->xml, null); xml_parser_free($this->xml); $this->test = str_repeat('xxxxx', 1000000); } public function handle_cdata(&$parser, $data) { } } for($i = 1; $i < 100; $i++) { $object = new c(); $object->test(); unset($object); var_dump(memory_get_usage(true) / (1024*1024)); } ?> Note that test will show the memory leak, but test2 and test3 don't. I don't know if that's the same as bug #72793 or not.