Devel::Events::Handler::ObjectTracker - A Devel::Events that tracks leaks
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);
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.
object_bless
object_destroy
This handler doesn't perform any magical stuff, Devel::Events::Generator::Objects is responsible for raising the proper events.
A Tie::RefHash::Weak hash that keeps an index of every live object and the object_bless event that created it.
Keeps a count of the live instances per class, much like Devel::Leak::Object.
USed to maintain the class_counters hash.
class_counters
Delegates to handle_object_bless or handle_object_destroy
handle_object_bless
handle_object_destroy
Adds an entry in the live_objects table.
live_objects
Munges event data into an entry for the live_objects table.
Decrements the class_counters counter.
To install Devel::Events::Objects, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::Events::Objects
CPAN shell
perl -MCPAN -e shell install Devel::Events::Objects
For more information on module installation, please visit the detailed CPAN module installation guide.