Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Greetings monks,

I found that my program (which is supposed to run for a long time) is leaking memory at each iteration it executes. I have already checked that by monitoring memory consumption by the process, by using Devel::Gladiator and Devel::FindRef.

Devel::Gladiator shows that my FSA::Rules instances are not being terminated as expected. I also added debug messages to the DESTROY method with syswrite to check if the object's are being terminated in the expected order. Here is what I got by running my test script:

$ perl t/DaemonHeavyLeak.t ListParser is gone End of program daemon is gone FSA::Rules=HASH(0x2faeea8) [refcount 2] is +- referenced by REF(0x2fa6ea8) [refcount 1], which is | not found anywhere I looked :( +- referenced by REF(0x27a1578) [refcount 1], which is the lexical '$self' in CODE(0x27978b8) [refcount 4], which is the global &FSA::Rules::DESTROY. FSA::Rules=HASH(0x2faeea8) [refcount 1] is referenced by REF(0x2fa6ea8) [refcount 1], which is not found anywhere I looked :( FSA::Rules is dead FSA::Rules=HASH(0x2e7a198) [refcount 2] is +- referenced by REF(0x2e7a768) [refcount 1], which is | not found anywhere I looked :( +- referenced by REF(0x27a1578) [refcount 1], which is the lexical '$self' in CODE(0x27978b8) [refcount 4], which is the global &FSA::Rules::DESTROY. FSA::Rules=HASH(0x2e7a198) [refcount 1] is referenced by REF(0x2e7a768) [refcount 1], which is not found anywhere I looked :( FSA::Rules is dead

Here is the testing code that I used:

use warnings; use strict; use Siebel::Srvrmgr::Daemon::Heavy; use Cwd; use File::Spec; use Scalar::Util qw(weaken); my $repeat = 3; my $daemon = Siebel::Srvrmgr::Daemon::Heavy->new( { gateway => 'whatever', enterprise => 'whatever', user => 'whatever', password => 'whatever', server => 'whatever', bin => File::Spec->catfile( getcwd(), 'srvrmgr-moc +k.pl' ), use_perl => 1, is_infinite => 0, timeout => 0, commands => [ Siebel::Srvrmgr::Daemon::Command->new( command => 'list comp', action => 'Dummy' ) ] } ); for ( 1 .. $repeat ) { $daemon->run(); } syswrite STDOUT, "End of program\n";

And the modified DESTROY of FSA::Rules:

sub DESTROY { my $self = shift; use Devel::FindRef; use Scalar::Util qw(weaken); syswrite STDOUT, Devel::FindRef::track $self; weaken($self); delete $machines{+shift}; syswrite STDOUT, Devel::FindRef::track $self; syswrite STDOUT, "FSA::Rules is dead\n" }

The correct order of messages of termination should be:

  1. FSA:Rules
  2. ListParser
  3. The program itself
  4. daemon

The thing is, at each execution of run(), a new FSA::Object is kept in memory unit program termination.

Besides, the message from Devel::FindRef:

+- referenced by REF(0x2e7a768) [refcount 1], which is | not found anywhere I looked :(

leaves me without hope to find what is happening.

There is anything else that I could do to detect where in the code this reference is being kept?

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 Missing reference and memory leak 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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (8)
    As of 2014-11-27 08:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (182 votes), past polls