Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^6: Memory leak question

by SBECK (Hermit)
on Oct 05, 2010 at 15:46 UTC ( #863624=note: print w/replies, xml ) Need Help??


in reply to Re^5: Memory leak question
in thread Memory leak question

WOW!!! I didn't expect you to do my debugging for me, but I really appreciate your help!

Although I like the syntax of the given/when better... it's not a big enough deal to me to fight with memory leaks over. I'll make all of the switches and be ready to test it out later today.

Thanks again.

Replies are listed 'Best First'.
Re^7: Memory leak question
by BrowserUk (Pope) on Oct 05, 2010 at 16:03 UTC

    NP. I really didn't do that much. I just looked inside to see if anything rang any bells, and the given/when thing did.

    But I was unsure of my memory, so I made the changes I described to confirm them before reporting them. I didn't want to groundlessly poison the construct.

      Okay, I've now changed all given/when to if/elsif/else, and it has improved things, but it is still leaking (just not as fast).

      I'd love to reduce the leakage even further. If I understand it correctly, one source of data leaks is if the value of a variable is actually a nested structure (so it has refs in it) and I set the value to something else, the old value is destroyed (assuming a refcount of 0), but any data referenced by it may not be automatically destroyed. Is that correct? I'm fairly sure that this happens, but I'm really not looking forward to a code audit of the thousands of lines of code to track this down.

      Is there a good tool that I can use that will tell me every line number in the module where a variable was set to a new value and the old value was destroyed, but part of it hung around? Then, I could recursively destroy the old value before I created a new value (there's probably even a module to help me do this).

      This, or any other suggestions would certainly be welcome. I'm afraid that in all the time I've been programming perl, I've never tried tracking down a memory leak, and I'm mainly just stumbling around in the dark I'm afraid.
        Is there a good tool that I can use that will tell me every line number in the module where a variable was set to a new value and the old value was destroyed, but part of it hung around? Then, I could recursively destroy the old value before I created a new value (there's probably even a module to help me do this).

        I'm the wrong person to ask. Most of the tools I've seen suggested for this--including Devel::LeakTrace & Devel::LeakTrace::Fast--don't run on my platform, so I've evolved other, source-code based, techniques.

        I've seen many references to a *nix tool: valgrind, but I've no experience of it.

        If you can send me a copy of your latest code, I could have a go using my limited techniques while you research the tools?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2019-04-25 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (125 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!