in reply to No garbage collection for my-variables

Another workaround is to re-exec the program, as outlined in:

How can I free an array or hash so my program shrinks?
  • Comment on Re: No garbage collection for my-variables

Replies are listed 'Best First'.
Re^2: No garbage collection for my-variables (exec code)
by tye (Sage) on Sep 16, 2008 at 04:16 UTC

    Hmm, that FAQ answer could do with some code:

    exec( $^X, $0, @ARGV ) or die "Can't execute self so killing self: $!\n";

    - tye        

      Nice!

      Also remember: don't shift your @ARGV ;-)

      But seriously, wouldn't it be more involved since we need to consider saving the program "state" and resume it somehow?
        But seriously, wouldn't it be more involved since we need to consider saving the program "state" and resume it somehow?

        Not always. In fact, quite often, if you do the exec when you aren't in the middle of something, that is all the code you need. Servers usually process transactions and it is usually a bad idea to have your stuff break because critical data is stored nowhere other than the memory of some service.

        - tye