Hi all, i have a great trouble with perl 5.16.3 activestate and tk 8.4 32. I need to update a tablegrid content every one second to display a changing matrix of data. I noticed that the call to refresh the view leaks memory, ie the memory uccupied by the script grows forever. Anyway I do not destroy or delete any row or widget and reuse always the same data container structure. The script is

use Tk; use Tk::TableMatrix; my $i=0; my $macchina_='38'; my $dbh; $mw = MainWindow->new; $mw->geometry("1000x600+0+0"); my $gridContainer={}; my ($rows,$cols) = (100, 16); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $gridContainer->{"$row,$col"} = " "; } } my $frameFermiDelTurno= $mw->Frame()->pack(-expand=>1,-fill=>'both' +); -orient=>"hori +zontal"); my $t = $frameFermiDelTurno->Scrolled('TableMatrix', -rows => $rows, -cols => $cols, -width =>500, -height => 14, -titlerows => 1, -titlecols => 1, -variable => $gridContainer, -selectmode => 'extended', -state => 'disabled', -bg => 'white', -font=> '{arial} 16 bold', -padx=>0, -ipadx=>0, -sparsearray=>0, -scrollbars=>'se' ); $t->tagConfigure('active',-bg => 'gray90', -relief => 'sunken' +); $t->tagConfigure('title', -bg => 'gray85', -fg => 'black', -re +lief => 'sunken'); $t->colWidth(2,20); $t->colWidth(3,20); # force scrollbar refresh: $t->pack( -expand=>1,-fill => 'x' , -side=>'left', -anchor=>'w +'); my $row=0; # $gridContainer->{"$row,0"} = "ID"; # $gridContainer->{"$row,1"} = "-"; # $gridContainer->{"$row,2"} = 'STATO'; # $gridContainer->{"$row,3"} = 'TURNO INIZIO'; # $gridContainer->{"$row,4"} = 'TURNO FINE'; # $gridContainer->{"$row,5"} = 'ORA INIZIO'; # $gridContainer->{"$row,6"} = 'ORA_FINE'; # $gridContainer->{"$row,7"} = 'ODL'; # $gridContainer->{"$row,8"} = 'LOTTO'; # $gridContainer->{"$row,9"} = 'NOTE'; # $gridContainer->{"$row,10"} = 'OPERATORE'; # $gridContainer->{"$row,11"} = 'CODICE PRODOTTO'; # $gridContainer->{"$row,12"} = 'CODICE_FERMO'; # $gridContainer->{"$row,13"} = 'DATA FINE'; # $gridContainer->{"$row,14"} = 'DATA INIZIO'; # $gridContainer->{"$row,15"} = 'DESCRIZIONE'; # $mw->repeat (1000,[ \&leak ]); MainLoop; sub leak{ TMRefresh(); } ###################################################################### sub TMRefresh{ ###################################################################### # this leaks $t->see("end"); # this leaks $->see("1,1"); $t->configure(-padx =>($t->cget(-padx))); #this leaks memory too my ($rows,$cols) = (100, 16); foreach my $row (0..($rows-1)){ foreach my $col (0..($cols-1)){ $gridContainer->{"$row,$col"} = int(rand(10)); } } $mw->update; }

Please , may you give me some advice if i am doing something wrong? I noticed that if I comment out the $t->see or $t->configure the table does not diplay anything other that column label but the memory allocated is costant. SO I think that the process of updating display has something that i don't understand ....Please help me. Thnak you a lot.


In reply to Tk::tablematrix update leaks memory by abonvici

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.