in reply to Subroutine Memory Leak

I think the problem is that you keep creating new Label objects. Since you don't destroy them, they just keep accumulating until you close the dialog. You should change the text of the existing label instead of creating a new Label every time autorefresh is called. I'm not familiar with Tk, so I can't help you with the syntax.

By the way, it's polite to say "Update: Added code snippet." or something of the kind when you update a node. It avoids confusion when existing replies refer to the original node content.

Replies are listed 'Best First'.
Re^2: Subroutine Memory Leak
by gopika77 (Initiate) on Jul 31, 2006 at 05:31 UTC
    I need help in detail..pls let me know how to use it
      The following changes will help:
      my $var = "Subroutine Memory Leak"; $mw->Label( -textvariable => \$var )->pack; sub autorefresh { # $var = $var + 20; $var += 20; return; }

      Don't create a label each time in sub autorefresh. You create a new label each time the sub is executed, but the previous one is still there. You are placing a label over a label over a label over a label...

      --shmem

      update: tested. Memory stays dead on at 7456/5064 VIRT/RES on my system.

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      i checked the code even just giving print to screen without TK the same memory leak