Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
What is required to free up memory used by Tk::TableMatrix when data in table is deleted (or get it to reuse the memory it has already consumed) instead of just grabbing more and more memory?

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; }

In reply to Tk::TableMatrix Memory Usage by ldln

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-29 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found