Posted on 2009-02-18 13:54:30-08 by meriadoc
Memory leak?
Hello, I'm afraid I'm fairly new to Perl so apologies in advance if I'm wasting anyone's time!
I'm using XML::Bare to process a very large XML file. I am using a sub as follows:
sub get_xml_tree { my $xml = $_[0]; my $xmlhandle = new XML::Bare(text => $xml); return $xmlhandle->parse(); }
The $xml is actually just a small chunk of xml, extracted from the original 4Gb xml file one record at a time. So I'm executing this sub up to a million times.

The problem is, I'm getting a memory leak - $xmlhandle doesn't seem to free up the memory when it goes out of scope in the sub.

What am I doing wrong?

Many thanks!

Meriadoc.
Direct Responses: 10012 | Write a response
Posted on 2009-02-18 20:06:37-08 by tttt in response to 10004
Re: Memory leak?
I am getting the same problem. The module looks great for my usage, but since I'm also doing multiple xml parsing, memory usage goes up very quickly, and I can't use the module.
Direct Responses: 10036 | Write a response
Posted on 2009-02-21 01:35:46-08 by codechild in response to 10012
Re: Memory leak?
I am looking into this problem. After a short review I have eliminated the main memory leaks. There is still memory leaking though; around 100 bytes per creation of an XML::Bare object. At least now this leak is constant and there are no larger leaks due to the XML itself.... something about the object.

If someone could develop a Devel::Leak module that doesn't depend upon a debug version of perl it would be quite helpful....

Will post again when all memory leaks are eliminated.
Direct Responses: 10040 | 10051 | Write a response
Posted on 2009-02-21 15:56:07-08 by tttt in response to 10036
Re: Memory leak?
Thanks a lot for the quick answer. Waiting for your next release now :)
Direct Responses: Write a response
Posted on 2009-02-23 08:37:39-08 by meriadoc in response to 10036
Re: Memory leak?
This is fantastic - look forward to the next release.
Cheers, Meriadoc
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.