Can I "hibernate" a program?

17

3

Yes, I know that hibernate usually applies to a computer. (Hibernate her meaning saving program memory in disk and being able to restore it in a consistent manner.)

However, hibernating a program can be very useful. Suppose I want to play a game, but a few programs like firefox, acrobat take up 500M of memory, so I want to free it up. Closing and then starting can be time-consuming, especially if session data cannot be stored. So instead I go and hibernate them. So is there any way I can hibernate a program?

apoorv020

Posted 2011-04-25T05:29:02.650

Reputation: 2 274

What OS are you using? – Ian C. – 2011-04-25T05:31:20.713

1Windows 7, 64-bit. I also retagged the question. – apoorv020 – 2011-04-25T05:32:32.650

nice improvement for a OS... – kokbira – 2011-04-25T16:10:59.207

2

Related( but no answers) http://superuser.com/questions/170434/save-and-restore-a-programs-state-in-windows

– Sathyajith Bhat – 2011-04-25T18:17:52.030

Answers

8

There's a related question about this over at StackOverflow. It's more programming related, but the main accepted answer explains why what you're trying to do is hard, and offers a viable alternative.

Basically, run your 'business' apps in a VM, and pause/hibernate/close it when you want to game.

Ƭᴇcʜιᴇ007

Posted 2011-04-25T05:29:02.650

Reputation: 103 763

4

While this is not an actual hibernate, the process can be suspended. It will immediately stop using CPU cycles, but is still will be using memory. Fortunately, this memory will be swapped to pagefile, if you launch any memory-intensive application afterwards, so it's not a real issue. Suspended process can't survive reboot\logoff, but this will be enough to play a game.

Related question: Suspend/Resume a process the easy way?

Internally, process suspending could be done via different approaches:

  • SuspendThread and ResumeThread function pair.

  • NtSuspendProcess function (not officially documented) that has been introduced with Windows XP Sp0 and works on every single system version since then.

  • Debugging Interface provided by Microsoft, using DebugActiveProcess and DebugActiveProcessStop functions. When a debugger attaches itself to a remote process, all the target’s threads immediately get suspended till the debugger gives a sign to let them execute.

There is a number of tools available, that can suspend a processes:

Moreover, Resource Monitor(Task ManagerPerformanceOpen Resource Monitor) in windows Vista and higher can suspend\resume processes:

Resource Monitor

beatcracker

Posted 2011-04-25T05:29:02.650

Reputation: 2 334

0

"Hibernating" an app wouldn't be any faster than just closing and restarting it, although your point about session data is valid. In general there wouldn't be much if any advantage.

CarlF

Posted 2011-04-25T05:29:02.650

Reputation: 8 576

5By what logic do you say that hibernating wouldn't be faster? Hibernating and restoring an OS is faster than a reboot. – apoorv020 – 2011-04-26T13:34:57.710

Think about what hibernating is. It requires copying the program image to hard disk, then copying it back. Closing the program and then restarting it only requires copying it from the hard disk. Windows starts up very slowly, for reasons I don't know. For other OS's, e.g. Linux, hibernating and awakening takes longer than just shutdown and reboot, at least on every system of mine I've tried it on. It's convenient but not fast. – CarlF – 2011-04-26T13:48:10.270

Well starting some programs is pretty slowtakes alot of time, especially firefox. Not to mention irritating as well. – apoorv020 – 2011-04-26T16:34:38.233

3Closing the program and then restarting it only requires copying it from the hard disk.   You are forgetting to add in the time it takes to get the program back into the state it was in. For example, re-opening a bunch of browser tabs, opening a file in an editor, etc. – Synetech – 2012-12-17T06:28:14.150

-2

Since you're on Windows, you could always create two user accounts and use the fast account switching function in windows and use each of them for different sets of apps. Since Windows pretty much hibernates the other seesions opened on the computer. I think so.

TripingPC

Posted 2011-04-25T05:29:02.650

Reputation: 34

2Switching between user accounts in Windows 7 does not hibernate or in any other way suspend activity in the non-active account. You can prove this to yourself by playing some audio in one account then switching to the other account and observing that the audio continues to play. – I say Reinstate Monica – 2015-03-04T02:50:02.227

Wellllllllll..... actually it does stop drawing the screen. – djsmiley2k TMW – 2016-09-15T12:53:57.120