in reply to Subroutine Memory Leak

As suggested above creating a new widget every tim ethe sub is called is not optimum. Try the following code with LEAK set to 1 and to 0 to see the difference in behaviour:

use warnings; use strict; use Tk; use constant LEAK => 1; my $var; my $handle; my $mw = MainWindow->new(); my $label = $mw->Label(-text=>"Subroutine Memory Leak")->pack; my $button = $mw->Button(-text=>"ClickMe", -command=>\&startloop)->pac +k; #&startloop; MainLoop; sub startloop { my $iid; $iid = $mw->repeat( 300,\&autorefresh) ; return; } sub autorefresh { $var++; if (LEAK) { $mw->Label(-text=>"$var",-font=>'arial 14 bold')->place(-x =>1 +00,-y =>50,-anchor => 'nw')->pack; } else { $label->configure (-text=>$var); } }

DWIM is Perl's answer to Gödel