Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Possible memory leak caused by configure(-cursor => ...)
#!/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


Report this thread to moderator Post Follow-up to this message
Old Post
David Thomas
05-02-05 02:03 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:27 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.