Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Tk::tablematrix update leaks memory

by zentara (Archbishop)
on Apr 18, 2014 at 09:04 UTC ( #1082732=note: print w/replies, xml ) Need Help??


in reply to Tk::tablematrix update leaks memory

Hi, one of the design features of many Tk list type widgets, is that they tend to keep an internal counter of all the list changes. For instance say you add 100 entries, internally they would be labeled 0..99. Now if you delete 0..99, and then try to add another fresh 100, their internal counter would range from 100... 199, even though you think of them as 0..99 because of their appearance on the screen.

So, just as with everything else in this world, it is best to learn to reuse things. An example is here: Tk::TableMatrix Memory Usage.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
  • Comment on Re: Tk::tablematrix update leaks memory

Replies are listed 'Best First'.
Re^2: Tk::tablematrix update leaks memory
by Anonymous Monk on Apr 18, 2014 at 11:43 UTC

    Thank you so much for your prompt answer. But seems to me that in my script the things are exactly as you say, ie i reuse the item of the container hash. I already read and tested your example script, and even if reusing the value of the hash ref that contains data the leaks happen anyway. I have tried my script with tcl::ptk instead of tk and after long time the memory seems stable with no leaks. To install tcl::ptk i need to pre-install activetcl and Class::ISA. Could be that tk 8.5 has a different behavior respect tk 8.4? I hope you can give me some ideas .Thank a lot .

      I hope you can give me some ideas

      I'm not an expert on TableMatrix, and if you want some advice, if you are experiencing trouble with it, I would dump the widget in favor of one that works for you.

      I would implement something on a Tk::Canvas or Tk::Zinc. The canvas handles thousands of items and changes very well. It's a bit more work, but you get to control every aspect of your widget. I wrote Tk-CanvasDirTree as an educational example to show how easy it is to make your own custm widget.

      The basic list and table widgets in Tk are simple widgets, and you can't expect too much from them.


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1082732]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2022-09-30 05:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?