Code Comments
Programming Forum and web based access to our favorite programming groups.#!/usr/bin/perl -w
#
# This program seems to leak memory when running under Perl 5.8.2
# and Tk 804.025 on i686-linux (compiled with gcc 2.96). It does
# not seem to leak on sun4-solaris. The leak goes away if the
# Listbox is removed, but the Listbox can be replaced with a Text
# widget and the leak still occurs.
#
# I have observed the same problem using $mw->Busy() and $mw->Unbusy(),
# which also use $w->configure(-cursor => ... ).
#
# Is this a known problem? Should I simply upgrade my Tk package?
# Have I overlooked something?
#
use strict;
use Tk;
sub toggle_cursor { my($mw, $countref) = @_;
my $count = ${$countref}++;
if ($count % 2) {
$mw->configure(-cursor => 'left_ptr');
} else {
$mw->configure(-cursor => 'watch');
}
$mw->after(1000, [ \&toggle_cursor, $mw, $countref ]);
}
sub leak3 {
my $count = 0;
my $mw = new MainWindow( -title => "leak3" );
my $buttons = $mw->Frame(-relief => 'groove', -borderwidth => 2);
my $cancel = $buttons->Button(-text => 'Cancel', -width => 6,
-command => sub { $mw->destroy() } )->pack(-side => 'left');
$buttons->pack(-side => 'top', -fill => 'x',
-ipadx => 2, -ipady => 2, -pady => 2);
my $listbox = $mw->Listbox()->pack(-fill => 'both', -expand => 1);
$listbox->insert('end', 'foo');
$listbox->insert('end', 'bar');
$listbox->insert('end', 'baz');
$mw->after(1000, [ \&toggle_cursor, $mw, \$count ]);
Tk::MainLoop();
}
leak3();
__END__
--
David Thomas (dthomas@ti.com)
Texas Instruments, Houston 281-274-2347
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.