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.
#!opt/project/COTS/bin/perl
use strict;
use warnings;
use Tk;
$Tk::mw = MainWindow->new;
$Tk::mw->repeat(10,\$build);
my $status;
&build;
sub build{
$status->destroy() if ($status);
$status = $Tk::mw->Frame->pack(-side => 'top');
my $left_frame = $status->Frame(
-relief =>'sunken',
-borderwidth => 1
)->pack(-side => 'left', -anchor => 'nw', -padx => 4, -pady => 5);
my $right_frame = $status->Frame(
-relief =>'sunken',
-borderwidth => 1
)->pack(-side => 'left', -anchor => 'nw', -padx => 4, -pady => 5);
}
MainLoop;