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

In reply to Re: Tk::NoteBook memory usage by zentara
in thread Tk::NoteBook memory usage by eXile

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.