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

In reply to How to interpret the results of Devel::Gladiator by glasswalk3r

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.