Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Tk::NoteBook memory usage

by zentara (Archbishop)
on May 10, 2004 at 13:27 UTC ( [id://352042]=note: print w/replies, xml ) Need Help??


in reply to Tk::NoteBook memory usage

You have to be very careful with Tk when you start deleting widgets. The Tk::DynaTabFrame has a nice demo which lets you add and delete notebook tabs. I've monitored the demo and the memory use increases as you add tabs, it holds constant as you delete tabs, and holds constant as you re-add tabs, until you exceed the previous max-tab number, when it starts to increase again.

This is just how you would expect it to work.

In your particular example, I think you are assuming that when you delete a tab, it disappears completely, and it's "internal tab number" is automatically made available for reuse. I don't believe it acts that way.

You seem to be just creating new tabs, up to infinity.

I have seen a similar problem with other widgets, specifically the HList, which I have been toying with lately. Say for instance I add 10 entries to the HList, the internal counter of HList numbers them from 0 to 9. Now if I delete them all, and then add 10 new entries, the internal numbering is now 10 to 19, NOT 0 to 9.

So you need to learn how to create a set number of widgets, and then reuse them over and over again.

I realize it would be easier if you could do it like you want, but it just dosn't work that way. It may have something to do with the TCL underneath perlTk, I am not that much of an internals expert. I have been toying with the idea of testing GTK2-perl for this, and see if it behaves in a similar manner, or whether it has a better internals design.


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

Replies are listed 'Best First'.
Re: Re: Tk::NoteBook memory usage
by flyingmoose (Priest) on May 10, 2004 at 14:07 UTC
    Given that, it should be possible to hid the tab, rip everything off of it, reconfigure it, and redisplay it then? Admittedly hackish, but you could create a Tk::NoteBook2 which was just a wrapper to a Tk::NoteBook, just would have to be very careful about how "fake-delete" was implemented in the subclass.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found