Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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":



  • 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 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? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-10-06 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?