in reply to Re^5: Out of memory with XML::Parser
in thread Out of memory with XML::Parser

I figured it out! After appending the characters from XML::Parser to my string I now undef the expat character variable. Suddenly the whole script moves way faster and uses less memory. This is the new character data handling routine:
Char => sub { my $expat = shift; my $chars = shift; $cbuffer = $cbuffer . $chars; undef $chars; }

Replies are listed 'Best First'.
Re^7: Out of memory with XML::Parser
by mirod (Canon) on Sep 15, 2005 at 14:22 UTC

    Do you get the same effect by replacing the undef $chars; by just... 1? It could be something like what's described in the XML::Twig FAQ: by having the last statement of the handler, which is returned to the calling routine, not evaluate to a huge string, you avoid copying it and thus get the effect you got.

    It looks like there was no bug in XML::Parser then, you just actually ran out of memory.

      Yep, same effect. The implicit return bit me is the ass :-) Thanks for helping me figure it our mirod!