Bug #76481 [NEW]: XMLReader::expand leaks memory over HTTP (but not over CLI)
| From: | tom dot denbraber at moxio dot com | Date: | Fri, 15 Jun 2018 09:42:15 +0000 |
| Subject: | Bug #76481 [NEW]: XMLReader::expand leaks memory over HTTP (but not over CLI) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-215735@lists.php.net to get a copy of this message | ||
From: tom dot denbraber at moxio dot com
Operating system: Debian 9.4
PHP version: 7.2.6
Package: XML Reader
Bug Type: Bug
Bug description:XMLReader::expand leaks memory over HTTP (but not over CLI)
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 bug report at https://bugs.php.net/bug.php?id=76481&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76481&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76481&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76481&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76481&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76481&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76481&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76481&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76481&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76481&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76481&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76481&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76481&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76481&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76481&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76481&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76481&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76481&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76481&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76481&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76481&r=mysqlcfg