Created
June 6, 2014 18:20
-
-
Save jkeroes/a9ae6be73fc6106d9a1e to your computer and use it in GitHub Desktop.
Perl and memory leak handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Memory leaks | |
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. | |
* Devel::SizeMe - Tim Bunce's graphical object dealie | |
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() | |
* Memory::Usage - http://perlmaven.com/eliminate-circular-reference-memory-leak-using-weaken (2013) | |
Display allocated and held memory: | |
* Devel::SizeMe - http://blog.timbunce.org/2012/10/05/introducing-develsizeme-visualizing-perl-memory-use/ | |
Sort me: | |
Devel::MAT | |
Test::MemoryGrowth | |
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 | |
http://blog.timbunce.org/2012/10/05/introducing-develsizeme-visualizing-perl-memory-use/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gerrit-trigger-plugint