Skip Menu |

This queue is for tickets about the IO-Async CPAN distribution.

Report information
The Basics
Id: 70236
Status: rejected
Priority: 0/
Queue: IO-Async

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

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



Subject: Memory/CPU leak with fast requeued timers
$ cat loop-timer-memleak.pl use strict; use warnings; use IO::Async::Loop; my $loop = new IO::Async::Loop; sub ioasync { $loop->enqueue_timer( delay => 0, code => $_[0] ); } my $id; sub cb { $id = ioasync \&cb; } my $count = 0; while(1) { $id = ioasync \&cb; $loop->loop_once; system "ps v $$" unless ++$count % 100; } $ perl -Mblib loop-timer-memleak.pl PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 9136 pts/11 S+ 0:01 0 1392 8975 5064 0.1 perl -Mblib loop-timer-memleak.pl PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 9136 pts/11 S+ 0:06 0 1392 9107 5156 0.1 perl -Mblib loop-timer-memleak.pl PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 9136 pts/11 S+ 0:14 0 1392 9107 5196 0.2 perl -Mblib loop-timer-memleak.pl PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 9136 pts/11 S+ 0:26 0 1392 9107 5240 0.2 perl -Mblib loop-timer-memleak.pl PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 9136 pts/11 S+ 0:41 0 1392 9239 5340 0.2 perl -Mblib loop-timer-memleak.pl PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 9136 pts/11 S+ 1:01 0 1392 9239 5440 0.2 perl -Mblib loop-timer-memleak.pl It also slows down quite a bit towards the end; the print interval gets a lot slower. -- Paul Evans
Actually, this is a bad test. The timer event enqueues another one every time it fires, but the while() loop -also- enqueues another one every time it iterates. So the number of timers increases, causing the queue to increase in size over time. The slowdown is due to it handling that number of timers all the time. -- Paul Evans
Bad example; code works fine. -- Paul Evans