in reply to Force perl to release memory back to the operating system

Whether or not a process can give back memory to the OS depends on the OS. And, AFAIK, on some OSses, Perl does give back memory to the OS.

In your case however, you are trying to fix your problem in the wrong way. There's no need to slurp in all the data in memory, if only you want to keep track of the top 30.

Here's an outline of a better algorithm:

Read in the first 30 records, sort them. Then process the other records one by one. If the record is larger than the smallest of the 30 records so far, remove the smallest, and add the newests (keep it in order).

Abigail

  • Comment on Re: Force perl to release memory back to the operating system

Replies are listed 'Best First'.
Re: Re: Force perl to release memory back to the operating system
by Anonymous Monk on Sep 25, 2003 at 16:42 UTC
    That's a damned good idea: much better implementation, as long as there is no record aggregation needed prior to sorting.