Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 11329
Status: resolved
Priority: 0/
Queue: POE

People
Owner: RCAPUTO [...] cpan.org
Requestors: sillydragon [...] pobox.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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; }
From: Jay Jarvinen jay-perl#3pound.com
[sillydragon@pobox.com - Wed Feb 2 00:58:41 2005]: Show quoted text
> 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
I had a similar problem, but it wasn't leaking as quickly. My primary box with POE-0.3009 from CPAN, on perl v5.8.4: It would take approximately 70 seconds to start leaking, then it would leak 4KB. Then for a next minute, the gaps between leaks were a bit random. But after a few minutes, it would settle on an average of 4KB every ~3 seconds. However, I then tested on my laptop, which had an older .deb version (libpoe-perl 0.29-1) installed, POE version 0.29, perl v5.8.4. And the leak was gone. Not wanting to downgrade, I grabbed it from CVS today (2005-03-16 13:52 -0600), and tried again on the primary box. And .. Thankfully, the leak appears to be gone in CVS: Repository revision: 1.6 /cvsroot/poe/poe/lib/POE/Loop.pm,v Repository revision: 1.312 /cvsroot/poe/poe/lib/POE/Kernel.pm,v Repository revision: 1.191 /cvsroot/poe/poe/lib/POE.pm,v Repository revision: 1.7 /cvsroot/poe/poe/lib/POE/Loop/TkActiveState.pm,v Repository revision: 1.12 /cvsroot/poe/poe/lib/POE/Loop/TkCommon.pm,v Repository revision: 1.43 /cvsroot/poe/poe/lib/POE/Loop/Tk.pm,v .. are some of the relevant CVS revision tags. -Jay p.s. A similar report was made in Nov 20004 by Jason Adams, "Tk memory leak workaround" (http://www.mail-archive.com/poe@perl.org/msg02266.html). Here's the script I was using: #!/usr/bin/perl -w use Tk; use POE; POE::Session->create( inline_states => { _start => \&ui_start, hello => \&hello_world, _stop => \&ui_stop, }, ); POE::Kernel->run(); exit(0); sub ui_start { $_[HEAP]->{start_time} = time(); $poe_main_window->Button(-text => 'Hello World', -command => $_[SESSION]->postback('hello'), )->pack(); $poe_main_window->Button(-text => 'Quit', -command => sub { exit(0); })->pack(); } sub ui_stop { my $elapsed_runtime = time() - $_[HEAP]->{start_time}; print 'Session ', $_[SESSION]->ID, " elapsed runtime: $elapsed_runtime\n"; } sub hello_world { warn "hello world\n"; }
From: Jay Jarvinen jay-perl#3pound.com
[guest - Wed Mar 16 16:07:28 2005]: Just to clarify, hopefully without confusing things further: Both machines I tested are Debian 'sarge', but my laptop versions are behind my "main" box. They also each run recent, but different kernels. Notably, perl-Tk V800.025 is behind. I didn't thoroughly test each and every version on the laptop. To recap, the "main" box: leaked with POE-0.3009 CPAN, Tk V804.027 upped to CVS, leak disappeared so I tried: cd ./cpan/build/POE-0.3009/; perl -Iblib/lib/ leaktest.pl .. and leak was there. I'm judging memory usage with a small Proc::ProcessTable script. sample (wrapped) output: Fri Mar 18 00:19:30 2005 [pid: 18136] size=> 10887168 (+/- 0) rss=> 8495104 (+/- 4096) [5sec] ... ... Fri Mar 18 00:45:41 2005 [pid: 18136] size=> 12914688 (+/- 0) rss=> 10612736 (+/- 4096) [2sec] ... Fri Mar 18 00:45:44 2005 [pid: 18136] size=> 13049856 (+/- 135168) rss=> 10616832 (+/- 4096) [3sec] ... Fri Mar 18 00:45:48 2005 [pid: 18136] size=> 13049856 (+/ - 0) rss=> 10620928 (+/- 4096) [4sec] ... At that rate, it could idle and grow at about ~4.7MB/hour, ~112MB/day (how I originally noticed). -Jay
[guest - Fri Mar 18 02:16:28 2005]: Show quoted text
> [guest - Wed Mar 16 16:07:28 2005]: > > Just to clarify, hopefully without confusing things further: > > Both machines I tested are Debian 'sarge', but my laptop versions are > behind my "main" box. They also each run recent, but different kernels. > Notably, perl-Tk V800.025 is behind. > > I didn't thoroughly test each and every version on the laptop. > > To recap, the "main" box: > leaked with POE-0.3009 CPAN, Tk V804.027 > upped to CVS, leak disappeared > > so I tried: > cd ./cpan/build/POE-0.3009/; perl -Iblib/lib/ leaktest.pl > .. and leak was there. > > I'm judging memory usage with a small Proc::ProcessTable script.
Unfortunately I get the leak in the CVS source on my main development machine, which means I can reproduce the problem so I can work on a fix. It's SO much easier when I can say "nope, doesn't happen for me". :) Anyway, fixes like the one at http://www.mail-archive.com/poe@perl.org/msg02266.html DON'T seem to correct the problem. I may need to heavily revise the Tk event loop code, which is a relatively large job (especially with the Win32 debugging) and means more delays until it's fixed. I just thought I'd let you know the ticket's not forgotten... just stalled while I scrounge up a big enough block of time.
Rewriting the core of POE::Loop::Tk seems to have solved it. The fix will be in POE 0.32. Thanks for the report and test case. USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND troc 4719 70.9 -0.4 41696 8304 p3 RN 1:13AM 0:10.43 perl test-leak-tk-2.perl troc 4719 73.7 -0.4 41696 8304 p3 RN 1:13AM 0:11.88 perl test-leak-tk-2.perl troc 4719 73.1 -0.4 41696 8304 p3 RN 1:13AM 0:12.87 perl test-leak-tk-2.perl troc 4719 66.1 -0.4 41696 8300 p3 RN 1:13AM 3:51.43 perl test-leak-tk-2.perl