Freeing memory for DOMDocument



I'm running through a large dataset and am generating/manipulating XML
documents for each record. What's happening is that after a while, I
get a fatal error saying:

Fatal error: Allowed memory size of 167772160 bytes exhausted (tried
to allocate 32650313 bytes)

Each XML file I generate (an manipulate) can range from just a few
megs to upwards of 35 megs. Judging from the error above, it looks
like the memory for the DOMDocument objects I instantiate is not
getting freed; it just continues to stay in memory until the memory is
completely exhausted. The method (in my object) I am using to
instantiate a new DOMDocument is as follows:

protected function createCleanDomDocument()
{
/*
if(( isset( $this->oDomXPath )) && ( !is_null( $this->oDomXPath )))
{
unset( $this->oDomXPath );
}

if(( isset( $this->oDomDocument )) && ( !is_null( $this->oDomDocument )))
{
unset( $this->oDomDocument );
}
*/
$this->oDomDocument = new DOMDocument( '1.0', 'iso-8859-1' );
$this->oDomXPath = new DOMXpath( $this->oDomDocument );
}

which is used in both the constructor of my object and in a few other
places. I would think that when the new DOMDocument is instantiated,
the memory used for the old value would get freed. As you can see,
I've even tried to unset the variables but that doesn't seem to help
matters much, either.

Does anyone know how (or even if) I can explicitly free the memory
used for the DOMDocument? Any help/advice would be greatly
appreciated!

thnx,
Christoph
.



Relevant Pages

  • Re: Freeing memory for DOMDocument
    ... Fatal error: Allowed memory size of 167772160 bytes exhausted (tried ... like the memory for the DOMDocument objects I instantiate is not ... unset($this->oDomDocument); ...
    (php.general)
  • Re: [PHP] Re: Freeing memory for DOMDocument
    ... >> like the memory for the DOMDocument objects I instantiate is not ... it just continues to stay in memory until the memory is ... AFAIK a variable becomes a candidate for gc when it is no longer required (unset and no references to it?) ... technically I'd guess that a script that loads an xml document in to a DOMDocument, then unsets it on a for loop should never grow the used memory. ...
    (php.general)
  • Re: INTERNAL_POWER_ERROR on Vista ..Ultimate 32bit,
    ... Is your system disk a plain SATA on a standard controller? ... Look at the hibernate file and see if it is a few MB ... larger than total memory size as reported on the "My Computer", ... The power policy manager experienced a fatal error. ...
    (microsoft.public.development.device.drivers)
  • Re: INTERNAL_POWER_ERROR on Vista ..Ultimate 32bit,
    ... Look at the hibernate file and see if it is a few MB larger than total memory size as reported on the "My Computer", ... "Tim Roberts" schrieb im Newsbeitrag ... A fatal error occured while preparing the hibernate file. ...
    (microsoft.public.development.device.drivers)
  • Re: "Am I still working okay?" asked the micro controller...
    ... >Say it will perform some realtime control of something. ... it was feasible to write one, or a small number, of "sanity checks", ... But when "Fatal Error nnnnn" pops up ... One other item that helped with the sanity checks, we filled all memory ...
    (comp.arch.embedded)