in reply to Re: memory leak when using tail recursion?
in thread memory leak when using tail recursion?

ikegami,
What version of perl? I ask because I see the memory leak locally with perl -v
This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 25 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 817 [257965] provided by ActiveState http://www.ActiveSta +te.com Built Mar 20 2006 17:54:25

Cheers - L~R

Replies are listed 'Best First'.
Re^3: memory leak when using tail recursion?
by ikegami (Patriarch) on Feb 14, 2007 at 00:10 UTC

    The exact same build.

    The memory usage does go up for each recursive call to bar (which is why I had to lower the max value for $i), but it does get reclaimed.

      ikegami,
      Very interesting. I am up over 200MB in 30 seconds if I use the block form of if. If I use the post modifier form of if, it stays fixed at 2MB.

      Cheers - L~R

        The if statememt creates a stack frame, while the statement modifiers do not. goto must reuse the sub's frame when possible. It apparently can't when the sub's frame isn't the topmost frame on the stack.