GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Devel::Events::Objects(3) User Contributed Perl Documentation Devel::Events::Objects(3)

Devel::Events::Objects - Object tracking support for Devel::Events

        use Devel::Cycle;
        use Data::Dumper;

        use Devel::Events::Handler::ObjectTracker;
        use Devel::Events::Filter::RemoveFields;
        use Devel::Events::Generator::Objects;

        my $tracker = Devel::Events::Handler::ObjectTracker->new();

        my $gen = Devel::Events::Generator::Objects->new(
                handler => Devel::Events::Filter::RemoveFields->new(
                        fields => [qw/generator/], # don't need to have a ref to $gen in each event
                        handler => $tracker,
                ),
        );

        $gen->enable(); # start generating events

        $code->(); # check for leaks in this code

        $gen->disable();

        # live_objects is a Tie::RefHash::Weak hash

        my @leaked_objects = keys %{ $tracker->live_objects };

        print "leaked ", scalar(@leaked_objects), " objects\n";

        foreach my $object ( @leaked_objects ) {
                print "Leaked object: $object\n";

                # the event that generated it
                print Dumper( $object, $tracker->live_objects->{$object} );

                find_cycle( $object );
        }

This package provides an event generator and a handler for Devel::Events, that facilitate leak checking.

There are two components of this module: Devel::Events::Generator::Objects, and Devel::Events::Handler::ObjectTracker.

The first one uses some trickery to generate events for every object creation and destruction in code loaded after it was loaded.

The second one will listen on these events, and track all currently living objects.

See the "SYOPSIS" for how to write your own leak tracker, and Catalyst::Plugin::LeakTracker for a real world application of these classes.

Devel::Events, Devel::Events::Filter::Size, Catalyst::Plugin::LeakTracker, Devel::Cycle, Devel::Leak::Object

Yuval Kogman <nothingmuch@woobling.org>

        Copyright (c) 2007 Yuval Kogman. All rights reserved
        This program is free software; you can redistribute it and/or modify it
        under the terms of the MIT license or the same terms as Perl itself.
2008-06-21 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.