Date: | Wed, 02 Feb 2005 00:46:11 -0500 |
From: | Saurian <sillydragon [...] pobox.com> |
To: | bug-poe [...] rt.cpan.org |
Subject: | Tk/POE leak example |
As promised on #perl on Feb 1st, here is a minimal Tk/POE script that
soaks up ever increasing amounts of RAM (at a rate of about 100K/sec on
my machine).
-- Sillydragon
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use POE;
POE::Session->create
( inline_states =>
{ _start => \&ui_start,
ev_count => \&ui_count,
ev_clear => \&ui_clear,
}
);
$poe_kernel->run();
exit 0;
sub ui_start {
my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];
$poe_main_window->Label( -text => "Counter" )->pack;
$heap->{counter_widget} =
$poe_main_window->Label( -textvariable => \$heap->{counter} )->pack;
$poe_main_window->Button
( -text => "Clear",
-command => $session->postback("ev_clear")
)->pack;
$kernel->yield("ev_count");
}
sub ui_count {
$_[HEAP]->{counter}++;
$_[KERNEL]->yield("ev_count");
}
sub ui_clear {
$_[HEAP]->{counter} = 0;
}