Greetings Monks,

I come to you today with a logistical problem rather than a programming one.
Firstly, I am doing this on a linux box.
I am working on a script which deals with very large arrays which will, if left to its own devices, fill up all the memory on a machine.
The most logical thing I can think of is a quick sub to swap in and out the contents of the array, so I'm not completely filling up the memory -- but the question is, for speed and efficiency, what should I swap the unused data out to?

Imagine a web spider that caches unchecked links as it goes by popping them onto an array. Leave it for a few hours/days, and eventually you're out of memory.
I figure what makes sense is keeping a number of entries in memory (say, 50,000), and popping all new 'URLs' onto an out-of-memory stack. When I have depleted my 50,000 URLs in my array, I swap 50,000 back in from the stack and carry on with those.
Making sense? Good. So -- how do I store the stack? A friend suggested using a RDBS, which would work - but could there be a faster way?

Thanks all,
JP

-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --


In reply to How to best handle memory intensive operations by JPaul

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.