NAME
Devel::Events::Handler::ObjectTracker - A Devel::Events that tracks leaks
SYNOPSIS
use Devel::Events::Handler::ObjectTracker;
use Devel::Events::Generator::Objects;
my $tracker = Devel::Events::Handler::ObjectTracker->new();
my $gen = Devel::Events::Generator::Objects->new(
handler => $tracker,
);
$gen->enable(); # start generating events
$code->();
$gen->disable();
use Data::Dumper;
warn Dumper($tracker->live_objects);
DESCRIPTION
This object will keep track of every object created and every object destroyed based on the object_bless
and object_destroy
events. Reblessing is accounted for.
This handler doesn't perform any magical stuff, Devel::Events::Generator::Objects is responsible for raising the proper events.
ATTRIBUTES
- live_objects
-
A Tie::RefHash::Weak hash that keeps an index of every live object and the
object_bless
event that created it. - class_counters
-
Keeps a count of the live instances per class, much like Devel::Leak::Object.
- object_to_class
-
USed to maintain the
class_counters
hash.