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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.