|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62467 SimpleXML memory usage is not reported by memory_get_usage()
Submitted: 2012-07-02 19:45 UTC Modified: 2012-07-05 08:00 UTC
From: zerkyn at gmail dot com Assigned:
Status: Wont fix Package: SimpleXML related
PHP Version: 5.3.14 OS: Windows, Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zerkyn at gmail dot com
New email:
PHP Version: OS:


 [2012-07-02 19:45 UTC] zerkyn at gmail dot com
When using SimpleXML functions to load XML data, the memory consumption is not tracked internally by PHP. 

Calling the "memory_get_usage()", you can see only a light memory consumption increase, which is clearly not an appropriate value for the document loaded (it is easily seen on a big documents, e.g. 1Mb+). However, the proper memory increase is observed by using system tools ('tasklist /FI "PID eq ..."' under Windows, 'ps' under Linux).

The issue affects profiling scripts, which are not able to fulfill their role. And it affects 'memory_limit' setting, which doesn't control application memory, consumed by SimpleXML.

Test script:
echo "Memory usage before: ", memory_get_usage(), "\n";
echo "Sys memory usage before: ", SystemMemoryUsage(), "\n";

$xml = simplexml_load_file('pretty_big_file_of_1mb_size.xml');

echo "Memory usage after: ", memory_get_usage(), "\n";
echo "Sys memory usage after: ", SystemMemoryUsage(), "\n";

/** -------------------------------------- */
function SystemMemoryUsage() 
... // Return memory consumption by executing system tool - tasklist, ps or anything else

Expected result:
"Memory usage after" and "Sys memory usage after" show, that memory consumption was increased by approximately same values.

Actual result:
"Memory usage after" shows light memory consumption increase, while "Sys memory usage after" shows much bigger value.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-05 08:00 UTC]
This can't be fixed; PHP doesn't control the way libxml2 does the allocations.
 [2012-07-05 08:00 UTC]
-Status: Open +Status: Wont fix
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Nov 27 09:03:13 2021 UTC