http://www.perlmonks.org?node_id=413619


in reply to How do I free memory allocated to an array

Given Abigail's answer above, it would then be wise to try to exit the script if that is possible. The task that requires the large array could be factored out into a script that could be run separately from within a larger script with fork or backticks or system or whatever. The tricky part would be if the task required a large amount of data to be passed to it. If the task required creating a large array and generating statistics on it or some such thing, then returning a comparitively small amount of data, then the benefit of keeping that a separate script could be large.