in reply to write hash to disk after memory limit
I'm not sure if I understand your question completely...
... but I once had a problem with a giant hash constantly swapping and solved it by splitting up the hash into a two tier HoH.
If you can organize the upper tier roughly according to the timeline of your process, your system will only swap the necessary lower hashes on demand.
I already described this here, will update the link after I found it.
HTH! :)
update
see Re: Small Hash a Gateway to Large Hash?
In Section
Seekers of Perl Wisdom