in reply to Memory management with long running scripts

Have a look at your callback subs. Do they make use of $self? Does $self keep reference to your event object? If so, you may want to:
weaken($self) if !isweak($self).
in your callback subs to get rid of circular refs.

Replies are listed 'Best First'.
Re^2: Memory management with long running scripts
by jamesrleu (Novice) on Aug 08, 2012 at 13:44 UTC
    This suggestion is interesting, but only causes more questions :-) Most of my Events are created like such:
    package Stuff; use strict; use Event; sub new { my $class = shift; my $self = {}; $self->{args} = [@_]; bless $self, $class; $self->{event} = Event->timer( interval => 1, cb => [$self, "read"], ); return $self; } sub read { my $self = shift; my $e = shift; # do work that uses values from $self }
    I see that $self and the {event} are technically a circular reference, but since I only create one instance of Stuff, it should not be a source of ongoing leaks. Is there something else I'm missing under the covers of Event?