Tk::Dialog memory leak?
Petr Pajas <[email protected]> Sat, 15 Jul 2006 10:32:58 +0200
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Organization | UFAL MFF UK |
| Message-ID | <[email protected]> |
Hi,
I have a dialog box which I cannot easily reuse, so it is created many times
during the application run. After creating it, I can't find a way to destroy
it completely even if I explicitly call $d->destroy all variables go out of
scope. Here is a demo:
#!/usr/bin/perl
use strict;
$|=1;
{
use Tk;
use Tk::Tree;
my $mw = MainWindow->new;
*Tk::Widget::DESTROY = sub {
my $w = shift;
print "DESTROYING $w\n";
$w->destroy if ($w->IsWidget);
};
{
for (1..3) {
print "===================================\n";
print "RUN $_\n";
print "===================================\n";
my $d=$mw->DialogBox(-title=> "test",
-buttons=> ["OK", "Cancel"]);
# only the Cancel button will get destroyed
my $edit1 = $d->HList(); # will get destroyed
my $edit2 = $d->Tree(); # won't get destroyed
$d->destroy;
# will destroy only Tk::Button a Tk::HList
sleep 0.1;
}
}
# MainLoop;
}
END {
print "===================================\n";
print "STARTING GLOBAL DESTRUCTION\n";
print "===================================\n";
# will destroy everything else
}
__END__
Is there any way to prevent the leak? Thanks,
-- Petr
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk