eXile has asked for the wisdom of the Perl Monks concerning the following question:
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:
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:#!/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();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::NoteBook memory usage
by biosysadmin (Deacon) on May 09, 2004 at 19:02 UTC | |
by eXile (Priest) on May 10, 2004 at 02:07 UTC | |
by asarih (Hermit) on May 10, 2004 at 14:07 UTC | |
|
Re: Tk::NoteBook memory usage
by zentara (Cardinal) on May 10, 2004 at 13:27 UTC | |
by flyingmoose (Priest) on May 10, 2004 at 14:07 UTC |