יובל קוג'מן (Yuval Kogman) > Devel-Events-Objects > Devel::Events::Handler::ObjectTracker

Download:
Devel-Events-Objects-0.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Stalled  1
View/Report Bugs
Source  

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.

METHODS ^

new_event @event

Delegates to handle_object_bless or handle_object_destroy

handle_object_bless @event

Adds an entry in the live_objects table.

event_to_entry @event

Munges event data into an entry for the live_objects table.

handle_object_destroy

Decrements the class_counters counter.

syntax highlighting: