Subject: | Memory leak in Tk::ProgressBar |
The attached script demonstrates a memory leak by using Tk::ProgressBar.
There is no memory leak with the same script and Tk 800.025. The only
change between both versions is the introduction of Tk::Trace, so I
think this is the cause. Probably the easiest fix: revert to the old
code.
Regards,
Slaven
# Problem:
# Speicherverbrauch wird immer groesser
use Tk;
use Tk::ProgressBar;
use Tk::LabEntry;
use Tk::Dialog;
use strict;
my $run = 0;
my $mw;
my $progress_stat;
my $progress_wert;
my $ende;
my $button_opentoolbar;
# Legt Hauptfenster Progressbar und Start-Button an
$mw=MainWindow->new(); #Hauptfenster
$mw->title("TK_Test"); #Name des Fensters
$mw->after(2000, \&run_idle);
$progress_stat = $mw->ProgressBar(-width => 20,
-length => 300,
-anchor => 'w',
-from => 0,
-to => 100,
-blocks => 50,
-colors => [0, 'light blue'],#);
-variable => \$progress_wert);
$button_opentoolbar = $mw->Button(-text => 'starten/stoppen',
-command => \&opentoolbar,
-width => 10);
$button_opentoolbar->pack(-side => 'right', -anchor => 's');
$progress_stat->pack(-side => 'right', -anchor => 's');
MainLoop();
sub run_idle ()
{
if ($run == 1)
{
$progress_wert++;
if ($progress_wert == 100) { $progress_wert = 0; };
};
$mw->after(50, \&run_idle);
};
sub opentoolbar ()
{
if ($run == 0) {$run = 1;}
else { $run = 0; };
print "run:$run\n";
if ($run == 1) { $progress_wert ++; };
};