On occasion, we would like to suspend memory-intensive processes on our Ubuntu and OS X servers to temporarily free up some RAM for other jobs.  If all we were worried about was CPU usage, a simple Ctrl-Z would work.  However, we need to be able to free up the RAM (by writing it to disk) and then restart the process (disk -> RAM) or in other words hibernate a single process.  Any clues on how to do this?  (Preferably from CLI.)  Thanks.
Suspend/resume single process to/from disk
process;memory;suspend
There is no general facility for hibernating a single process, only the whole system.However, if you don't care that the process image won't survive a reboot, there is a built-in facility for saving the process image to disk: swapping. Make sure you have enough swap space, and if there is memory pressure and the process is not active (for example because it is suspended), its memory will be swapped out.If you know that the process is likely to be inactive for a long time and that you're going to need a fast response time at some point, you can force a lot of RAM to be freed now by allocating a lot of RAM in a short-duration process, e.g.perl -e '$tmp = a x 999999999' # allocate about 1GBYou don't get any control on what gets swapped out, so other processes may get swapped out. On Linux, you can swap a process back in by forcibly accessing the pages it maps. The script in this answer will do that: load to memory all the pages mapped by a process (note that this includes open files; you can traverse regions selectively based on the map information to avoid swapping in data that you know you won't need, see this answer for more information).