Subject: | Memory leak in AnyEvent::Handler for TLS connections |
Hey!
While write test for our web-application using AnyEvent::HTTP, I've
discovered that it badly leaks a memory if I using https. Attached
script may be used to reproduce the problem. It's memory usage grows
rapidly even after maximum number of connections reached. I investigated
and found that the problem is in the AnyEvent::Handler code. Patch for
AnyEvent::Handler is attached. It solves problem for me.
Great code btw. Thanks.
Subject: | foo.pl |
#!/usr/bin/perl
use strict;
use warnings;
use EV;
use AnyEvent;
use AnyEvent::HTTP;
my $url = "https://127.0.0.1/";
#my $url = "http://127.0.0.1/";
my @sessions;
my $w = AnyEvent->timer( after => 1, interval => 1, cb => \&start_sessions );
my $total = 0;
my @watchers;
EV::loop;
sub start_sessions {
warn "Total: $total\n";
return if $total > 2000;
my $count = 70;
for my $i ( 1 .. $count ) {
my $num = $total;
http_get $url, sub { http_callback($num) };
$total++;
}
}
sub http_callback {
my $num = shift;
warn "42!\n" if $num == 42;
my ( $data, $headers ) = @_;
$watchers[$num] = AnyEvent->timer(
after => 30,
cb => sub { timer_callback($num) },
);
}
sub timer_callback {
my $num = shift;
http_get $url, sub { http_callback($num) };
}
Subject: | AnyEvent-Handle_freetls.patch |
--- lib/AnyEvent/Handle.pm.orig 2009-03-25 18:55:41.000000000 +0300
+++ lib/AnyEvent/Handle.pm 2009-03-25 18:56:45.000000000 +0300
@@ -1475,7 +1475,7 @@
}
sub DESTROY {
- my $self = shift;
+ my ($self) = @_;
&_freetls;