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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello,

I have an application that parses largish tab delimited files (typically a few million rows) and writes out files suitable for bulk loading into a postgres database. Unfortunately, it seems to leak memory; after processing a few 100,000 lines, the processes starts to crawl, as swap gets used up and not long after that, the OS starts killing things.

When I realized that I had a memory leak, I figured I knew exactly where the problems was: I was using a few hashes to keep track of IDs that I was generating for a few of the tables. Simple enough--I tied those hashes to DB_File and the problem should be solved, right? Well, if it were, I wouldn't be writing this, would I?

Heading off to cpan, I found Devel::Leak, Devel::LeakTrace, Devel::Leak::Object and Devel::ObjectTracker. Unfortunately again, none of these seem to help much. Devel::Leak is quite low level, and so I don't really know how to use it. Ditto for Devel::LeakTrace. If anyone has suggestions for how to use it for finding the leak, I'm all ears/eyes.

Devel::ObjectTracker seemed promising. It is well documented and several configurable options, including allowing it to track hashes and arrays in addtion to objects. Unfortunately (I am getting tired of using that word), it seems to ignore all the settings for the options, and doesn't print anything other than table column headings in its output.

Devel::Leak::Object seemed to also have promise. When using it, it overloads the bless function to allow tracking of creation and destruction of objects. While this worked, it only showed two objects remaining at the completion of the main loop: one is a small config-fetching object that I could easily destroy before the loop, but there is no way that is leaking, and the other is the object that handles IO, and the author of that object insists that it can't be leaking either (there are no package variables in the object).

So, if anyone has suggestions for where to go from here, I'd really appreciate seeing them.

thanks much,

Scott
Project coordinator of the Generic Model Organism Database Project


In reply to Tracking down memory leaks by scain

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-06-24 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.