Bug #63380 [Asn]: Allocation via libxml does not use PHP's per-request allocator

From: Date: Mon, 29 Oct 2012 21:55:03 +0000
Subject: Bug #63380 [Asn]: Allocation via libxml does not use PHP's per-request allocator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174411@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63380&edit=1

 ID:                 63380
 Updated by:         tstarling@php.net
 Reported by:        tstarling@php.net
 Summary:            Allocation via libxml does not use PHP's per-request
                     allocator
 Status:             Assigned
 Type:               Bug
 Package:            XML related
 Operating System:   Linux
 PHP Version:        master-Git-2012-10-29 (Git)
 Assigned To:        rrichards
 Block user comment: N
 Private report:     N

 New Comment:

https://github.com/php/php-src/pull/223


Previous Comments:
------------------------------------------------------------------------
[2012-10-29 03:25:17] tstarling@php.net

Description:
------------
Allocation via libxml does not use PHP's per-request allocator. So any memory used by libxml
will not be accounted against memory_get_usage() or memory_limit.

At Wikimedia we use libxml DOM trees to store wikitext parse trees, because they are more compact in
memory than the equivalent pure-PHP data structures. When these parse trees are cached, the memory
requirements can become excessive, and the memory is typically not returned to the system after
request termination. Using xmlMemSetup() to set hook functions which use PHP's per-request
allocation functions will allow us to more effectively monitor and limit the use of libxml in
production.

I've developed a patch and will submit it to GitHub as a pull request.

Test script:
---------------
$doc = new DOMDocument;
for ( $i = 0; $i < 1000000 ; $i++ ) {
    $doc->appendChild($doc->createElement('foo'));
}
print memory_get_usage()."\n";


Expected result:
----------------
312331440 (with debug and ZTS)

Actual result:
--------------
694256


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63380&edit=1


Thread (7 messages)

« previous php.bugs (#174411) next »