Doc #72793 [Ver->Csd]: xml_parser_free leaks mem when execute xml_set_object
| From: | cmb@php.net | Date: | Fri, 12 Aug 2016 10:57:26 +0000 |
| Subject: | Doc #72793 [Ver->Csd]: xml_parser_free leaks mem when execute xml_set_object | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13804@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72793&edit=1
ID: 72793
Updated by: cmb@php.net
Reported by: daisukeunoz1zi at gmail dot com
Summary: xml_parser_free leaks mem when execute
xml_set_object
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: *XML functions
Operating System: CentOS
PHP Version: 7.0.9
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=92a076a92bf7d2fb20e0bc5d376ce65fab268b52
Log: Fix #72793: xml_parser_free leaks mem when execute xml_set_object
Previous Comments:
------------------------------------------------------------------------
[2016-08-12 10:46:31] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=339867
Log: Fix #72793: xml_parser_free leaks mem when execute xml_set_object
------------------------------------------------------------------------
[2016-08-12 09:50:02] cmb@php.net
This issue affects PHP 7 only, and there it can't be fixed without
causing a considerable BC break.[1] Instead the user of
xml_set_object() has to make sure to break the reference cycle
between the parser and the custom object (typically by unsetting
the parser when they're done). This has to be documented.
[1] <http://marc.info/?t=147082649400006&r=1&w=2>
------------------------------------------------------------------------
[2016-08-09 07:17:27] daisukeunoz1zi at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.xml-parser-free
---
The memory usage of the script below goes through the roof.
It happen only when execute "xml_set_object".
It does not happen when I execute "unset($this->parser);".
Test script:
---------------
<?php
class xml {
var $parser;
function __construct()
{
$this->parser = xml_parser_create();
xml_set_object($this->parser, $this);
}
function parse($data)
{
xml_parse($this->parser, $data);
}
function free(){
xml_parser_free($this->parser);
//unset($this->parser);
}
}
$xml_test = '<?xml version="1.0"
encoding="utf-8"?><test></test>';
for ($i = 0; $i < 100000000; $i++) {
$xml_parser = new xml();
$xml_parser->parse($xml_test);
$xml_parser->free();
unset($xml_parser);
}
?>
Expected result:
----------------
Empty output.
Actual result:
--------------
Out of memory error.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72793&edit=1