Monks,

I have the following code

sub 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; }
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 removeData
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; }
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,

Grygonos

In reply to Need Help Identifying Possible Tk Memory Reuse Problem by Grygonos

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.