php.net |  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
 [2012-07-02 19:45 UTC] zerkyn at gmail dot com
Description:
------------
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:
---------------
<?php
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-05 08:00 UTC] cataphract@php.net
This can't be fixed; PHP doesn't control the way libxml2 does the allocations.
 [2012-07-05 08:00 UTC] cataphract@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 13:01:26 2024 UTC