How to free up memory "fully hibernating" a process?

Similar to this: How to "hibernate a process" under Linux/Windows?

Are there any methods to hibernate a process in a way that it doesn't stay in memory? E.g.: If I don't want to use Firefox, and don't want to close the process of it, and I need free memory, then how can I really hibernate the process so the memory reserved by Firefox is freed up?

I need solution for both Windows and Linux!


Solution 1:

If I don't want to use Firefox, and don't want to close the process of it, and I need free memory, then how can I really hibernate the process so the memory reserved by Firefox is freed up?

For Windows, there is Free Process Freezer.

For Linux and Mac OS X, there is CrypoPID, as mentioned in yeedl's answer.


If you want to come up with a custom solution:

Look into process dumping on Windows, eg. ProcDump, resume it with a CLI debugger from WinDBG.

Look into core dumping on Linux, eg. core, resume it with a CLI debugger like GNU GDB.

I bet a software based solution that doesn't involve a debugger is possible, but that's for Stack Overflow.


You're looking for a very specific use case, why don't just suspend and let it swap out?

You would be spending more time on getting your processes running and suspending...

I believe you can optimize your workflow in another way that would be more seamless.

Solution 2:

Both Windows and Linux/Unix provide a way to suspend or stop a process from executing, by removing it from the list of runnable processes.

This doesn't directly affect the memory pages owned by a process, but over time as the system comes under pressure for memory those pages will be good candidates to swap out to disk.

Trying to write out a process to disk for later resumption isn't going to work for anything non-trivial. Open handles to the network and windowing system will fail as soon as the process resumes.

Solution 3:

I know in firefox you can save a session.

In Linux, this can be done with CrypoPID.

This question and this one try to answer it for Windows, but I couldn't find a great solution of saving an application state to a file like I did for linux.

Solution 4:

For Windows:

I don't know any way to completely evict a process from memory without killing it, but you can trim its working set by minimizing its main window. Microsoft has an article explaining this: The working set of an application is trimmed when its top-level window is minimized.

So, first minimize the main window(s), then suspend the process as suggested in the question you linked.

You can accomplish both with the ever-useful Process Explorer.

  • Right click process, Window -> Minimize
  • Right click again, Suspend.