ldln has asked for the wisdom of the Perl Monks concerning the following question:
In test script below we fill up table with data. When table is emptied memory usage stays the same (about 138_000 KB) and when we fill up table again with new data, memory just increases more and more.. Hopefully I just missed the boat somewhere.
MSWin32|perl5.8.7|Tk804.027
Thanks for advice.
use warnings; use strict; use Tk; use Tk::TableMatrix::Spreadsheet; $| = 1; my $mw = tkinit; my $NumCols = 50; our $tmVar = {}; our $TM_Table = $mw->Scrolled('Spreadsheet', -variable => $tmVar, -sparsearray=>1, -titlerows => 1, -titlecols => 1, -scrollbars => 'se', -selectmode => 'extended', -rows=>1, -cols=> $NumCols, -resizeborders => 'both', -wrap=>1, -bd=>1, -cache=>0, -selecttitle=>1, -colstretchmode => 'none', -rowstretchmode => 'none', -rowheight => 1, -drawmode=>'fast')->pack(-expand=>1,-fill=>'both'); $mw->Button(-text=> 'Fill Tablematrix', -command => \&FillTM)->pac +k; $mw->Button(-text=> 'Clear Tablematrix', -command => \&ClearTM)->p +ack; #Top row $TM_Table->set("0,$_", $_) for (0..$NumCols-1); MainLoop; sub FillTM { my $Rows = 5000; $TM_Table->insertRows("0.0", $Rows); for my $Row (1..5000) { $mw->update if (not $Row % 500) xor $TM_Table->see("$Row,0"); for (0..$NumCols-1){ $TM_Table->set("$Row,$_",qw(111 222)[int rand 2] x 50 ); } } } sub ClearTM { #$TM_Table->deleteRows('-keeptitles', '0.0', $TM_Table->cget(-rows +)); $TM_Table->deleteRows( '0.0', $TM_Table->cget(-rows)); $TM_Table->clearAll('0,0','end'); undef $tmVar; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::TableMatrix Memory Usage
by zentara (Cardinal) on Nov 09, 2005 at 13:32 UTC | |
by ldln (Pilgrim) on Nov 09, 2005 at 21:26 UTC | |
by zentara (Cardinal) on Nov 10, 2005 at 12:46 UTC |