Hi,

I'm working on a perl/Tk program that contains a Tk::Notebook were regularly tabs (or 'pages' as they are called in the documentation) are added and deleted. I've noticed everytime a tab is added and deleted my memory usage goes up, so I've reduced the problem to this piece of code:

#!/usr/bin/perl use strict; use warnings; $| = 1; use Tk; use Tk::NoteBook; use Devel::Size qw(total_size); use Data::Dumper; my $mw = MainWindow->new(); my $nb = $mw->NoteBook()->pack; my $i; my $amount = $ARGV[0]; $amount ||= 20; print "0 tabs:\n"; print "total_size " . total_size($nb) . "\n"; print Dumper($nb); print "\n-------------\n"; for ($i=0;$i<$amount;$i++) { my $p1 = $nb->add("$i", -label => "$i"); $p1->Label(-text => "aap" x 100)->pack(); } for ($i=0;$i<$amount;$i++) { $nb->delete($i); } print "0 tabs: (after removing $amount tabs)\n"; print "total_size " . total_size($nb) . "\n"; print Dumper($nb); print "\n-------------\n"; ##MainLoop();
When I run this code on my PC (FreeBSD4.9 perl5.8.2 Tk804.025 (also tried Tk804.027 but same results)) after adding and removing tabs the memory usage of the Tk::Notebook increases, and the Data::Dumper output shows the '_names_'-hash inside of the blessed Tk::NoteBook-hash still contains the names of the tabs I deleted, so this obviously still takes up some memory.

This raises a lot of questions for me:

In reply to 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.