|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-11-12 17:01 UTC] mikep at oeone dot com
<?php
echo "starting test ...<p>";
flush();
for ($i=0; $i<100; $i++)
{
$doc = xmldocfile( "SOMEXMLFILE" );
}
echo "test finished";
?>
When this is done on Apache, the memory used by Apache sky rockets. The larger the XML file, the larger the memory leak.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 22:00:01 2025 UTC |
I need a way to attach a file to this bug... Here is the diff: diff -ur php-4.0.6/ext/domxml/php_domxml.c php-4.0.6-haxx0red/ext/domxml/php_domxml.c --- php-4.0.6/ext/domxml/php_domxml.c Thu May 24 08:41:46 2001 +++ php-4.0.6-haxx0red/ext/domxml/php_domxml.c Tue Nov 13 17:26:03 2001 @@ -71,6 +71,7 @@ PHP_FE(domxml_set_attribute, NULL) PHP_FALIAS(domxml_setattr, domxml_set_attribute, NULL) PHP_FE(domxml_children, NULL) + PHP_FE(xmldocfree, NULL) //oeone PHP_FE(domxml_new_child, NULL) PHP_FE(domxml_node, NULL) PHP_FE(domxml_unlink_node, NULL) @@ -205,7 +206,7 @@ domxmltestnode_class_startup(); #endif - le_domxmldocp = zend_register_list_destructors_ex(php_free_xml_doc, NULL, "domxml document", module_number); + le_domxmldocp = zend_register_list_destructors_ex(php_free_xml_doc, php_free_xml_doc, "domxml document", module_number);//oeone /* Freeing the document contains freeing the complete tree. Therefore nodes, attributes etc. may not be freed seperately. */ @@ -1161,6 +1162,38 @@ zend_list_addref(ret); } /* }}} */ + +//oeone +PHP_FUNCTION(xmldocfree) +{ + zval *id, **tmp; + xmlDoc *docp; + xmlNode *node; + int ret; + + /* php_error( E_WARNING, "Oeone Destructor\n" ); */ + if (ZEND_NUM_ARGS() == 0) { + id = getThis(); + if (id) { + if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) { + php_error(E_WARNING, "unable to find my handle property"); + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp) + } else { + RETURN_FALSE; + } + } else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) { + WRONG_PARAM_COUNT; + } else { + if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) { + php_error(E_WARNING, "unable to find my handle property"); + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp) + } + xmlFreeDoc(docp); +} /* {{{ proto object domxml_new_child([int node_handle,] string name, string content) Adds child node to parent node */ diff -ur php-4.0.6/ext/domxml/php_domxml.h php-4.0.6-haxx0red/ext/domxml/php_domxml.h --- php-4.0.6/ext/domxml/php_domxml.h Thu May 24 08:33:43 2001 +++ php-4.0.6-haxx0red/ext/domxml/php_domxml.h Tue Nov 13 17:26:03 2001 @@ -46,6 +46,7 @@ PHP_FUNCTION(domxml_add_root); PHP_FUNCTION(domxml_intdtd); PHP_FUNCTION(domxml_dumpmem); +PHP_FUNCTION(xmldocfree); //oeone /* Class Node methods */ PHP_FUNCTION(domxml_attributes);