in reply to Occupancy of Perl functions, variables etc

If the script mostly consumes memory and CPU, it oughtn't crash a properly tuned operating system. If you're on Unix, check out limits (ulimit with bash, limit with (t)csh, etc.) and avoid running the script as root.

After you've got that set up, you can safely run the script on smaller datasets and try to see why it goes wild. Does it not reuse resources? Must it keep track of everything at the same time, or can the job be split up to smaller tasks? It's hard to give more specific advice without more specific knowledge of your problem, but these are the kind of questions to ask.