Subject: | Binding using anonymous functions leaks memory |
#!/usr/local/bin/perl
use Tk;
my $mw = MainWindow->new;
my $button;
$button = $mw->Button(-text=>'Click', -command=> sub{
for my $i (1..102400){
$button->bind("<Button-2>", sub{});
}
})->pack();
MainLoop;
The process grows by about 1.6MBytes every time you press the button, which suggests that 16 bytes of memory are being leaked for every call to bind. The problem also exists in other types of bindings (like using tagBind on a ROText widget).
Tk version is 800.023
Perl's version is v5.6.1.
OS is `SunOS 5.8 (sparc)'.
It also happens on `Linux 2.4.24 (i686)'.