public
Last active

Perl memory leaks resources

  • Download Gist
perl-memory-modules
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 
Tracking memory leaks:
Devel::Arena - sv_stats() returns arena structures used for SV allocation
* Devel::Cycle - find_cycle($ref) returns all cycles found in $ref and the perl variables they point to
Devel::Gladiator - walk Perl variable arena
Devel::Leak - deprecated by Devel::LeakTrace::Fast
Devel::LeakTrace - deprecated by Devel::LeakTrace::Fast
* Devel::LeakTrace::Fast - prints leaked SV's and line numbers at END.
Data::Structure::Util - has_circular_ref($ref) returns ref to link in $ref that is circular or false.
Test::LeakTrace - no_leaks_ok(), etc.
Test::Memory::Cycle - Based on Devel::Cycle, offers memory_cycle_ok(), etc.
 
Tracking XS memory leaks:
Devel::Peek - Core module that dumps perlguts info. The examples section has useful perlguts explanations.
Devel::Plumber - use gdb to find and report leaks
Devel::Valgrind::Client - related to Test::Valgrind.
Test::Valgrind - just tracks Newx and malloc-like, not perl objects.
 
Memory allocation size:
Devel::Size - print size with and without ref traversals.
* Devel::Size::Report - print full report of every ref in a var.
 
Object-only:
Devel::Events::Handler::ObjectTracker - track every blessed obj created or destroyed via object_bless() and object_destroy()
Devel::Leak::Object - track select or every blessed obj
Devel::LeakGuard::Object - derived from Devel::Leak::Object; adds leakguard { ... } closure.
 
Fixing memory leaks:
* Data::Decycle - can also decycle coderefs! weaken_deeply(), decycle_deeply(), recsub { ... } - leak free closures
Data::Structure::Util - circular_off($ref) - traverse $ref for cyclical refs and weaken them.
* Object::Destroyer - create sentries for objects and inform them what to do during destruction
Scalar::Util - weaken()
Sub::Recursive - anonymous memory leak free subs. mutually_recursive(), recursive()
 
Articles on leaks:
How to use Object::Destroyer: http://www.perl.com/pub/2007/06/07/better-code-through-destruction.html
PM leak article collection: http://www.perlmonks.org/?node_id=336883
http://www.perlmonks.org/?node_id=419754
http://perldoc.perl.org/perldebguts.html#Debugging-Perl-memory-usage

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.