Subject: | MListbox memory leaks |
This is happening with Tk::MListbox 1.11. I tested it on Fedora Core 2 and Windows 2000.
I am observing memory leak when using MListbox. The leak happens both when deleting/re-inserting the list and when sorting. I monitored the memory leak by using "top" in Linux and using the task manager in Win2k.
The memory seems to go up by the same amount every time. I could not find the source of this problem. The problem may lie in Tk::Listbox itself and not MListbox, I can't say for sure.
The attached script demonstrates the problem. Everytime the button is clicked or the column is sorted, the script leaks memory.
#!/usr/bin/perl -w
use strict;
use Tk;
use Tk::MListbox;
my $mw = Tk::MainWindow->new(-title => 'MListbox Leak');
my $b = $mw->Button(-text => 'Leak', -command => \&leak)->pack(-side=>'bottom');
my $mlb = $mw->Scrolled('MListbox', -scrollbars=>'se', -selectmode=>'extended',)
->pack(-expand=>'true', -fill=>'both', -side=>'top',);
$mlb->columnInsert('end', -text=>'Test');
#setup the initial indices
for(1..10000)
{
$mlb->insert('end',[$_]);
}
MainLoop;
sub leak
{
$mlb->delete(0,'end');
for(0..10000){
$mlb->insert($_,[$_]);
}
$mlb->update;
}