Skip Menu |

This queue is for tickets about the AnyEvent CPAN distribution.

Report information
The Basics
Id: 44575
Status: resolved
Priority: 0/
Queue: AnyEvent

Owner: Nobody in particular
Requestors: zwon [...]

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

Subject: Memory leak in AnyEvent::Handler for TLS connections
Download (untitled) / with headers
text/plain 436b
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.
text/x-perl 838b
#!/usr/bin/perl use strict; use warnings; use EV; use AnyEvent; use AnyEvent::HTTP; my $url = ""; #my $url = ""; 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/ 2009-03-25 18:55:41.000000000 +0300 +++ lib/AnyEvent/ 2009-03-25 18:56:45.000000000 +0300 @@ -1475,7 +1475,7 @@ } sub DESTROY { - my $self = shift; + my ($self) = @_; &_freetls;
Subject: Re: [ #44575] Memory leak in AnyEvent::Handler for TLS connections
Date: Thu, 26 Mar 2009 06:12:50 +0100
To: "Pavel I. Shaydo via RT" <bug-AnyEvent [...]>
From: Marc Lehmann <schmorp [...]>
Download (untitled) / with headers
text/plain 2.1k
Hi! You sent a possible bug report on or via Please read this mail carefully if you want to be heard. Most likely, your report will be ignored. Please close the ticket again and sent it to the official contact address for the module in question (or send it to Why is this necessary? has many deficiencies which makes it tedious and hard to use, increasing the workload on the people who provide all the perl modules you probably appreciate (and that is really to be avoided - module authors should be able to invest all their time into improving their modules and not fighting with's bugs). Still, for some people, is useful to have, and some people even like it and really want to use it. That is fine, too. Unfortunately, the designers of didn't make their "service" optional - you can neither opt-in nor opt-out of as a module author. Just like a spammer, forces its "service" (whether wanted or unwanted) on everybody. Just like a spammer, they don't care for the people they actively hurt. Just like a spammer, they don't don't care to fix these issues and make their "service" ethically acceptable. You cannot even configure it to redirect tickers to somewhere else. Unfortunately, ignoring is not an option either: for people reporting possible bugs there is no indication that their report will be ignored, and for module authors it means they miss possibly vital bug reports (and of course it's a great impression if has lots of bug reports that are unanswered, making a module unmaintained when in fact the opposite might be true). This is why it is important that you delete your ticket again. I am sorry that this wasted a bit of your time, but please understand that I am just as much a victim as you are - the problem is the unethical stance of the providers who force their "service" on everybody. Please redirect your bug report as stated in the beginning of this mail, and please consider petitioning the providers to stop their unethical behaviour and allow opt-in, opt-out, or some redirect option. Thanks a lot, Marc Lehmann <>
Sent mail directly to author as requested -- Pavel Shaydo

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to