glasswalk3r has asked for the wisdom of the Perl Monks concerning the following question:

Greetings monks,

I'm using Devel::Gladiator to try to identify memory leaks in a program that I'm developing. I'm getting a report from it like this:

ARRAY|1321|1465|1573 CODE|536|551|566 FSA::State|20|30|40 GLOB|953|954|954 HASH|274|313|352 REF|566|798|994 REF-ARRAY|158|272|350 REF-CODE|97|142|187 REF-FSA::State|56|84|112 REF-HASH|90|129|168 REF-Regexp|12|18|24 Regexp|12|18|24 SCALAR|10156|10303|10447

This output was generated with the following methods created for a new class that depends on the return of arena_ref_counts method from Devel::Gladiator: (see increment_count method below):

package Test::Gladiator; use Scalar::Util qw(weaken); use Cwd; use File::Spec; sub new { my $class = shift; my $file = File::Spec->catfile( getcwd(), 'gladiator_output.txt' ) +; open( my $out, '>', $file ) or die "Cannot create $file: $!"; my $self = { counting => {}, out_h => $out }; return bless $self, $class; } sub DESTROY { my $self = shift; close( $self->{out_h} ) or die $!; } sub show_accounting { my $self = shift; my $out = $self->{out_h}; foreach my $key ( sort( keys( %{ $self->{counting} } ) ) ) { print $out $key, '|', join( '|', @{ $self->{counting}->{$key} +} ), "\n" if ( $self->{counting}->{$key}->[1] > $self->{counting}->{$key} +->[0] ); } } sub count_leaks { my $self = shift; my $total = 0; foreach my $key ( keys( %{ $self->{counting} } ) ) { my $last = $#{ $self->{counting}->{$key} }; $total++ if ( $self->{counting}->{$key}->[$last] > $self->{counting}->{$key}->[ $last - 1 ] ); } return $total; } sub increment_count { my $self = shift; my $current = shift; weaken($current); foreach my $key ( keys( %{$current} ) ) { if ( exists( $self->{counting}->{$key} ) ) { push( @{ $self->{counting}->{$key} }, $current->{$key} ); } else { $self->{counting}->{$key} = [ $current->{$key} ]; } } } 1;

The report shows each item is being increased at each interaction of the test. For the rows that begin with "ref", it is easy to understand what is happening and how to address the leak. But what about the following rows?

ARRAY|1321|1465|1573 CODE|536|551|566 GLOB|953|954|954 HASH|274|313|352 SCALAR|10156|10303|10447

How one should interpret those results? Should I worry about them? They are related to the main package? Or they are related to counting of all respective object (for instance, all array references used in the program for the ARRAY line)? Shouldn't those rows be related to their specific package where they were declared (for instance, Test::Gladiator::ARRAY or something like that)?

Thank you,

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Replies are listed 'Best First'.
Re: How to interpret the results of Devel::Gladiator (typeglobs)
by Anonymous Monk on Dec 08, 2013 at 17:57 UTC