Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Missing reference and memory leak

by chromatic (Archbishop)
on Oct 04, 2013 at 18:40 UTC ( #1056916=note: print w/ replies, xml ) Need Help??


in reply to Missing reference and memory leak

This looks suspicious:

        delete $machines{+shift};

Do you mean $self instead of +shift? That may not solve the original problem, but it might help you debug further.


Comment on Re: Missing reference and memory leak
Select or Download Code
Re^2: Missing reference and memory leak
by glasswalk3r (Pilgrim) on Oct 04, 2013 at 22:50 UTC

    In fact, the code:

    delete $machines{+shift};

    is from the original author of FSA::Rules. I just added the debug messages and the Devel::FindRef.

    You were right about your guess: I moved the usage of Devel::FindRef to the scope of ListParser class and could get the message:

    FSA::Rules=HASH(0x31cc818) [refcount 13] is +- referenced by REF(0x31d8740) [refcount 1], which is | the member 'machine' of HASH(0x31cc788) [refcount 1],

    Later, in the DESTROY, Devel::FindRef gave me the same HASH address.

    After a fair amount of time checking the code of FSA::Rules, I got this (I pasted only the interesting parts):

    I created a new method to loop over %machines and %states and setting the references to the FSA::Rules object to undef. and invoked it at the end of parse method from ListParser.

    After that, I could finally get the object termination in the moment that I want:

    Thanks!

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

      Am I understanding that your original usage was based on code examples from the module's POD? If those examples contribute to leaky code, you might do the community a favor by submitting a bug report for the module's POD.


      Dave

        Actually, the examples of the Pod were not quite helpful for me because I need to use the state machine to parse several lines of data. I evaluated the module in CPAN and my suggestions were to improve the Pod regarding that.

        Regarding the possible memory leak in the module itself (at least for the comments I made in this node, I'm sure they are not in my code) I had opened an issue in the respective Github account of the distribution.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2014-09-20 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls