Bug #76481 [Com]: XMLReader::expand leaks memory over HTTP (but not over CLI)
| From: | tom dot denbraber at moxio dot com | Date: | Fri, 22 Jun 2018 13:17:30 +0000 |
| Subject: | Bug #76481 [Com]: XMLReader::expand leaks memory over HTTP (but not over CLI) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215858@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76481&edit=1
ID: 76481
Comment by: tom dot denbraber at moxio dot com
Reported by: tom dot denbraber at moxio dot com
Summary: XMLReader::expand leaks memory over HTTP (but not
over CLI)
Status: Open
Type: Bug
Package: XML Reader
Operating System: Debian 9.4
PHP Version: 7.2.6
Block user comment: N
Private report: N
New Comment:
This problem is probably related to https://bugs.php.net/bug.php?id=76520.
Previous Comments:
------------------------------------------------------------------------
[2018-06-15 11:36:38] tom dot denbraber at moxio dot com
I also tested the situations mentioned above in PHP 7.1.18, but the bug does not occur in that
version.
------------------------------------------------------------------------
[2018-06-15 09:42:12] tom dot denbraber at moxio dot com
Description:
------------
XMLReader::expand does not free its allocated memory.
When executing the test script below using the CLI, the memory usage is as expected. However, when
serving the same script over HTTP (via Apache or nginx), the XMLreader::expand function does not
free its memory. For larger XMLs, this is a problem.
Because the problem only occurs when serving the script over HTTP, I do not know whether this is a
'Network Functions'-issue, and 'XML Reader'-issue or a 'Web
Server'-issue. Feel free to re-categorize.
Test script:
---------------
<?php
$xml_string = "<?xml version=\"1.0\"?>
<items>";
for ($i = 0; $i < 50000; $i++) {
$xml_string .= sprintf("<item id=\"bk%d\"></item>", $i);
}
$xml_string .= "</items>";
$reader = new XMLReader();
$reader->XML($xml_string);
print memory_get_usage() . "\n";
while ($reader->read() === true) {
$node = $reader->expand();
}
print memory_get_usage() . "\n";
Expected result:
----------------
The first and second memory-usage prints should be roughly equal to each other (this happens when
executing the script using the CLI).
Actual result:
--------------
When executed over HTTP, the second memory usage is a lot higher than the memory usage that was
printed first. For the given script, often up to 66% higher.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76481&edit=1