Grygonos has asked for the wisdom of the Perl Monks concerning the following question:
I have the following code
I had asked for opinions on the gui setup in a previous SoPW node, but now I come with a different question. The call back that references \&removeData has a possible memory leak. Here is the code for removeDatasub guiStart { my ($client,$login) = @_; my $mw = MainWindow->new(-borderwidth=>30, -title=>"Duplicates: ".$$client); my %layout = ('frame' => [], 'label' => [], 'callback'=> []); #Construct labels $layout{'label'}->[0] = 'List Available Data'; $layout{'label'}->[1] = 'Remove Data'; $layout{'label'}->[2] = 'Add Data'; $layout{'label'}->[3] = 'Identify Duplicates'; $layout{'label'}->[4] = 'Change Client'; $layout{'label'}->[5] = 'Exit Application'; #Set callbacks $layout{'callback'}->[0] = [\&listData,$client,$login,$mw]; $layout{'callback'}->[1] = [\&removeData,$client,$login,$mw]; $layout{'callback'}->[2] = [\&addData,,$client,$login,$mw]; $layout{'callback'}->[3] = \&identifyDuplicates; $layout{'callback'}->[4] = \&changeClient; $layout{'callback'}->[5] = \&exitApp; for (0..5) { #Create the frames $layout{'frame'}->[$_] = $mw->Frame(); #Create the buttons $layout{'frame'}->[$_]->Button(-text =>$layout{'label'}->[$_ +], -width =>20, -command=>$layout{'callback'}-> +[$_])->pack(); $layout{'frame'}->[$_]->pack(); } MainLoop; return; }
If I open this dialog box from the callback, the memory usage goes up. If I close it and re-open it .. it continues to go up. I fail to see why this would happen. Am I missing something obvious? Are there good tools that can help me identify this on my own? Thanks,sub removeData { my ($client,$login,$mw) = @_; my @tapes = getTapes($client,$login); #Create a DialogBox my $dlg = $mw->DialogBox(-title =>"Delete tape for: ".$$clien +t, -buttons =>['Delete','Cancel'], -borderwidth=>5); my $list = $dlg->Scrolled('Listbox', -scrollbars=>'oe os', -background=>'black', -foreground=>'white', -height =>12, -width =>12)->pack(); $list->insert('end',$_) for @tapes; + my $choice= $dlg->Show(); my $num = $list->get($list->curselection()); #If the user chose Delete if(lc($choice) eq 'delete') { #Drop the listbox $list->packForget(); #Reconfigure the dialog title $dlg->configure(-title =>'Delete Confirmation!'); #Reconfigure the dialog button text $dlg->Subwidget('B_Delete')->configure(-text=>'Yes'); $dlg->Subwidget('B_Cancel')->configure(-text=>'No'); $dlg->Label(-text=>"Tape:".$num." will be deleted. Are you su +re?")->pack(); if(lc($dlg->Show()) eq 'yes') { my $success = deleteTape($client,\$num,$login); } } return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Help Identifying Possible Tk Memory Leak
by eserte (Deacon) on Jul 12, 2004 at 16:17 UTC | |
by Grygonos (Chaplain) on Jul 12, 2004 at 16:39 UTC | |
by graff (Chancellor) on Jul 13, 2004 at 04:32 UTC | |
by Grygonos (Chaplain) on Jul 13, 2004 at 12:58 UTC | |
|
Re: Need Help Identifying Possible Tk Memory Leak
by pg (Canon) on Jul 12, 2004 at 15:43 UTC | |
|
Re: Need Help Identifying Possible Tk Memory Reuse Problem
by zentara (Cardinal) on Jul 13, 2004 at 14:24 UTC | |
by Grygonos (Chaplain) on Jul 13, 2004 at 15:14 UTC |