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)->pack; #&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 =>100,-y =>50,-anchor => 'nw')->pack; } else { $label->configure (-text=>$var); } }