Devel::Gladiator - Walk Perl's arena
version 0.07
use Devel::Gladiator qw(walk_arena arena_ref_counts arena_table); my $all = walk_arena(); foreach my $sv ( @$all ) { warn "live object: $sv\n"; } warn arena_table(); # prints counts keyed by class # how to spot new entries in the arena after running some code my %dump1 = map { ("$_" => $_) } walk_arena(); # do something my %dump2 = map { $dump1{$_} ? () : ("$_" => $_) } walk_arena(); use Devel::Peek; Dump \%dump2;
Devel::Gladiator iterates Perl's internal memory structures and can be used to enumerate all the currently live SVs.
This can be used to hunt leaks and to profile memory usage.
Returns an array reference containing all the live SVs. Note that this will include a reference back to itself, so you should manually clear this array (via @$arena = ()) when you are done with it, if you don't want to create a memory leak.
@$arena = ()
Returns a hash keyed by class and reftype of all the live SVs.
This is a convenient way to find out how many objects of a given class exist at a certain point.
Formats a string table based on arena_ref_counts suitable for printing.
arena_ref_counts
This code may not work on perls 5.6.x and 5.8.x if PadWalker is installed. (Patches gratefully accepted!)
Become a hero plumber Test::Memory::Cycle Devel::Cycle Devel::Refcount Devel::Leak Data::Structure::Util
Artur Bergman <sky@apple.com>
This software is copyright (c) 2006 by Artur Bergman.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Karen Etheridge <ether@cpan.org>
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
Jesse Luehrs <doy@tozt.net>
Brad Fitzpatrick <brad@danga.com>
Ed J <mohawk2@users.noreply.github.com>
Curtis Brandt <curtisjbrandt@gmail.com>
To install Devel::Gladiator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::Gladiator
CPAN shell
perl -MCPAN -e shell install Devel::Gladiator
For more information on module installation, please visit the detailed CPAN module installation guide.