http://www.perlmonks.org?node_id=863622


in reply to Re^4: Memory leak question
in thread Memory leak question

does this indicate that maybe the problem isn't (directly) with Date::Manip?

You might be right.

One source of leaks is the routine _iso8601_rx(). If you modify it:

sub _iso8601_rx { return ''; ...

This doesn't leak any more:

#!/usr/bin/perl -slw use Date::Manip::Date; $date = new Date::Manip::Date; #use Devel::LeakTrace::Fast; for (1..100e6) { $date->parse("2010-02-01 01:02:03"); }

Now that routine uses an extensive given/when construct, which I've had problems with in the past. And I think I've read other bug reports alluding to memory leaks associated with that construct previously.

To confirm my suspicion, I commented out the given( $rx ) { line and closing brace, and replaced all the whens with an if/elsif/else cascade. The result was that the rate of memory leak reduced markedly. Perhaps to 1/10 of the rate.

You do have 6 other given/when constructs in the file and I strongly suspect that if you replaced those similarly with if/elsif/else cascades, your memory leaks would abate even further, if not completely.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.