Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: XML::Twig loves to eat my memory

by AndyZaft (Hermit)
on Jul 22, 2010 at 20:17 UTC ( [id://850902] : note . print w/replies, xml ) Need Help??


in reply to XML::Twig loves to eat my memory

I'm sure mirod will tell you sooner or later what you can do to make it better. Maybe it's just needs another purge/flush before the dispose to tell twig that it is finished with the root element too.

Replies are listed 'Best First'.
Re^2: XML::Twig loves to eat my memory
by AndyZaft (Hermit) on Jul 22, 2010 at 20:30 UTC
    Something else just occurred to me is that in this case it might be beneficial to use twig_roots since you are only interested in 1 field anyway. Probably not going to help with the memory issues much in the end, but it might crash later :)
      twig_roots does prove to be most useful for when you only want one little bit of data. A single file only consumes 19MB as opposed to 166MB. However it still does not release memory when I try to $t->dispose(). This also does not solve my problem for scripts that have to process all the data.

        However it still does not release memory when I try to $t->dispose().

        How did you ascertain that?

        Very strange, since dispose calls the Twig object's destructor explicitly. But then again I don't know much about how the GC works in the Perl process. So your memory usage keeps growing the more files you process if I'm understanding this correctly, right?