Devel::Monitor

Devel::Monitor is a Perl module that can monitor your variables/objects for memory leaks.
Download

Devel::Monitor Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Philippe Cote
  • Publisher web site:
  • http://search.cpan.org/~phcote/Devel-Monitor-0.9.0.7/lib/Devel/Monitor.pm

Devel::Monitor Tags


Devel::Monitor Description

Devel::Monitor is a Perl module that can monitor your variables/objects for memory leaks. Devel::Monitor is a Perl module that can monitor your variables/objects for memory leaks.You have memory leaks, and you want to remove it... You can use this tool to help you find which variables/objects that are not destroyed when they should be, and thereafter, you can visualise exactly where is the circular reference for some specific variables/objects.WHAT IT CAN'T DOEven if your modules are memory leak free, it doesn't mean that external modules that you are using don't have it. So, before running your application on mod_perl, you should be sure that EVERY modules are ok. (In particular those perl extensions calling C++ code)SYNOPSIS use Devel::Monitor qw(:all); #----------------------------------------------------------------------------- # Monitor scalars, arrays, hashes, references, constants #----------------------------------------------------------------------------- my ($a,$b) = (Foo::Bar->new(), Foo::Bar->new()); my ($c, @d, %e); use constant F => ; monitor('name for a' => $a, 'name for b' => $b, 'name for c' => $c, 'name for d' => @d, 'name for e' => %e, 'name for F' => &F); #NOTE : Dont add parentheses to the end of the constant (&F()) #----------------------------------------------------------------------------- # Print circular references #----------------------------------------------------------------------------- # NOTE : You cannot use print_circular_ref on a monitored/tied variable # (See "We cannot use tied objects references because it reuse memory space" doc) print_circular_ref($a); print_circular_ref($b); print_circular_ref($c); print_circular_ref(@d); print_circular_ref(%e); print_circular_ref(&F); #NOTE : Dont add parentheses to the end of the constant (&F())USAGE : monitorExample with a circular reference +----------------------+ | Code | +----------------------+ { my @a; monitor('a' => @a); $a = @a; #Add a circular reference print STDERR "Leaving scopen"; } print STDERR "Scope leftn"; +----------------------+ | Output | +----------------------+ MONITOR ARRAY a Leaving scope Scope left DESTROY ARRAY a +----------------------+ | Meaning | +----------------------+ The line "DESTROY ARRAY a" should be between scope prints. @a were deleted on program exit.Example without a circular reference +----------------------+ | Code | +----------------------+ { my @a; monitor('a' => @a); print STDERR "Leaving scopen"; } print STDERR "Scope leftn"; +----------------------+ | Output | +----------------------+ MONITOR ARRAY a Leaving scope DESTROY ARRAY a Scope left +----------------------+ | Meaning | +----------------------+ Everything is okNow that you know there is a circular reference, you can track it down using the print_circular_ref methodRequirements:· Perl Requirements: · Perl


Devel::Monitor Related Software