php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #24015 DOMXML: xpath->free()
Submitted: 2003-06-04 09:12 UTC Modified: 2004-08-27 10:22 UTC
From: rbro at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.3.2 OS: RedHat 7.3
Private report: No CVE-ID: None
 [2003-06-04 09:12 UTC] rbro at hotmail dot com
While the following script is running, the RAM usage increases greatly when it should just remain relatively constant because free() is being used.  Upon further investigation, if I comment out the $xpath line, the RAM usage remains constant, so it's something with creating/using a xpath object and then trying to free the entire domxml object later.

<?php
$xml = '<root><a></a></root>';
for ($i = 1; $i <= 50000; $i++)
{
	$dom = domxml_open_mem($xml);

	$xpath = xpath_new_context($dom);

	$dom->free();
}
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-04 10:30 UTC] rrichards@php.net
As illustrated in your example, without the xpath context usage, memory uage remains constant. DomDocument->free will just free the document in memory. The memory increase you see is coming from the xpath objects you keep creating.
 [2003-06-04 10:43 UTC] rbro at hotmail dot com
Thanks for your reply - How do I free() the xpath object in the middle of my loop?  I don't believe there is a xpath->free() function.
 [2003-06-04 10:58 UTC] rrichards@php.net
Currently you cant. You can add it as a feature request, but I cant say when or if it will be implemented.
 [2003-06-04 11:56 UTC] rbro at hotmail dot com
Where would I go to add a feature request?  Also, do you have any short-term workarounds for this?  I currently have a CLI script trying to process several thousand xml streams, and right now, it's using up all my RAM (512 MB) and all my virtual memory.  Thanks.
 [2003-06-04 23:10 UTC] sniper@php.net
reclassified.

 [2004-08-27 10:22 UTC] chregu@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC