title: Perl/Tk Memory Leak When Using destroy() Command
body: <p>I am having an issue with a large leak in Perl/Tk running on Unix.  I am unable to post most of the code due to certain restrictions, but I have been able to identify what is causing the memory leak and create a small program that has the same symptoms.  Basically I am running a GUI where a frame is destroyed and repopulated regularly.  This seems to cause a large memory leak that keeps growing however.  I thought the destroy command would get rid of all traces in memory, but it does not seem to be that way.  I am not too familiar with the garbage collection in Perl either.  This program will be running for days or weeks at a time and so a memory leak is not ideal.  Does anyone have any ideas to stop the memory leak?  I am restricted to using Perl, so unfortunately I cannot just easily port the code to Python or something.  Thanks for help in advance.</p>
  
  <pre><code>#!opt/project/COTS/bin/perl
  use strict;
  use warnings;
  use Tk;
  
  $Tk::mw = MainWindow-&gt;new;
  $Tk::mw-&gt;repeat(10,\$build);
  my $status;
  &amp;build;
  
  sub build{
      $status-&gt;destroy() if ($status);
      $status = $Tk::mw-&gt;Frame-&gt;pack(-side =&gt; 'top');
  
      my $left_frame = $status-&gt;Frame(
          -relief =&gt;'sunken',
          -borderwidth =&gt; 1
      )-&gt;pack(-side =&gt; 'left', -anchor =&gt; 'nw', -padx =&gt; 4, -pady =&gt; 5);
  
      my $right_frame = $status-&gt;Frame(
          -relief =&gt;'sunken',
          -borderwidth =&gt; 1
      )-&gt;pack(-side =&gt; 'left', -anchor =&gt; 'nw', -padx =&gt; 4, -pady =&gt; 5);
  
  }
  MainLoop;
  </code></pre>