in reply to Re: Why I got nearly out of memory, and never recover from that?
in thread Why I got nearly out of memory, and never recover from that?

I think the Op has a "memory leak" for some reason. There are a bunch of ways that this could happen. But this post is right, Perl will re-use memory if it can. It NEVER gives memory back to the O/S and there are many ways that Perl memory gets "re-cycled" within Perl.

A "long lived" Perl program will grow to a maximum memory "footprint" and THEN that size remains constant. If you see that memory is always increasing (and not "leveling off"), then one of your objects is not releasing its memory for Perl to recycle. The main point here is that a Perl program will reach a max memory size and that's it!

  • Comment on Re^2: Why I got nearly out of memory, and never recover from that?

Replies are listed 'Best First'.
Re^3: Why I got nearly out of memory, and never recover from that?
by llancet (Friar) on Jun 16, 2009 at 07:20 UTC
    To all above:

    The most direct problem it caused is: it seems using hard disk prior than "true" memory, which caused the program runs rather slow. How could I improve it?

      You'll need to modify your program so it doesn't need as much memory at once.

      The most direct problem it caused is: it seems using hard disk prior than "true" memory, which caused the program runs rather slow. How could I improve it?
      It's not surprising your program uses the disk a lot. In your original post, you say your program reads in a large file. Said file lives on disk. To get it from disk, it needs to use the disk. Hence the disk usage.

      Of course, it could also mean you're using so much memory the process is swapping to disk. In that case, you may want to look at your program again and see whether you really need to complete file in memory.