php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37458 XPath Memory Leak
Submitted: 2006-05-16 08:11 UTC Modified: 2006-05-16 11:03 UTC
From: lars dot kirchhoff at unisg dot ch Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
 [2006-05-16 08:11 UTC] lars dot kirchhoff at unisg dot ch
Description:
------------
If xpath->query is used in combination with namespaces in the xml document it produces a memory leak. The memory leak couldn't be identified with memory_get_usage. Only top could show us the raising memory usage.

Reproduce code:
---------------
#!/usr/local/apache2/bin/php
<?php 

$xml_str = '<?xml version="1.0" encoding="UTF-8"?>
            <items xmlns:a="http://www.example.org/" xmlns:b="http://www.example2.org/" xmlns:c="http://www.example3.org/" >
            <header>Item1</header>
            <item>Data</item>
            </items>
           ';

$xml_dom = DomDocument::loadXML( $xml_str );
$xpath = new domXPath( $xml_dom );   
for( $i=0; $i< 1000000; $i++ ) {
    $node_list = $xpath->query( '/*' );    
}

?>

Expected result:
----------------
The memory usage of the above code WITHOUT the namespace definition is 1.1% (using top). 

Actual result:
--------------
The memory usage of the above code WITH the namespace definition is starting by 1.1% and raising up to 7.4%(using top). 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-16 11:03 UTC] rrichards@php.net
Not a PHP issue. Leak is in libxml2. will be fixed there.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC