wolis has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Can anyone shed any light on the status of the memory leak in XML::DOM::Parser?

As mentioned here 251630

I installed XML-Parser-2.34 - however I'm using Perl 5.6.1

Does this mean (since the node states the leak is fixed) that the problem is with Perl 5.6.1 more than XML::DOM::Parser? - I'd rather not have to update Perl to 5.8.0 since its all working nicely (apart from this leak) now.

Thanks,

___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com/cow

Replies are listed 'Best First'.
Re: resolution of XML::DOM::Parser memory leak
by gellyfish (Monsignor) on Aug 20, 2004 at 09:07 UTC

    There is potentially a separate issue with apparent memory leaks in XML::DOM::Parser and those that may or may not have been fixed in XML::Parser. You may experience memory leaks in XML::DOM if you are creating many lexical DOM objects and just letting them go out of scope without caling the Dispose method on them before you do so, this is because there may be (intentional) circular references in the DOM object in memory. I have the same problem with XML::XSLT which uses XML::DOM under the covers and creates a number of DOM objects to hold intermediate results and parts of the template and so forth and it appears to leak like a sieve when processing a large number of documents with the same object.

    /J\

      Ah.. thanks for that.. makes perfect sense.

      A quick check of the script and 'dispose' has not been used - adding it at the appropriate spot fixes everything! (woo hoo)

      Mind you the XML file is 2Mb yet 42Mb are used when its loaded - disposing of it, doesnt free up all that memory but loading other XMLs (or reloading the same one) does not continue expand this memory usage (phew)

      I can live with this.

      Thanks again.

      ___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com