Is there a way to snapshot a running process to disk to restore it later?

11

4

I usually work with a lot of instances of visual studio open to different projects, I was wondering if there is a way to snapshot/hibernate a running process to disk instead of closing it so that I can open it in the same state as it was quickly.

I have a ton of free disk space so wouldn't mind saving the entire process snapshot if it would save me the time in opening up the solution and waiting for the projects to load.

Sijin

Posted 2010-06-11T15:19:13.183

Reputation: 211

+1: Interesting idea! (Of course this is exactly what the virtual memory manager is trying to do for you automatically as and when required.) – Andy – 2010-06-11T15:24:32.080

2

FWIW, something like this ("unexec", based on a core dump) is traditionally part of the build process for Emacs on UNIX systems. See, for example, http://www.xemacs.org/Architecting-XEmacs/unexec.html

– coneslayer – 2010-06-11T15:31:00.383

1That was specifically designed for emacs no? I wonder if a general purpose version could be written. – Andy – 2010-06-11T15:47:20.600

I have been searching for something like this for quite some time now. It would especially help if you wanted to pause a video encoder! – Breakthrough – 2010-06-11T17:31:17.280

1It seems like there is something like this for Linux linux.org/apps/AppId_2488.html However I think the problem is going to be open file handles, network sockets etc., which make this a non-trivial problem – Sijin – 2010-06-11T17:52:49.723

Yeah, restoring state appropriately would require knowing how the program works. For example, the process assumes that files it has locked won’t be modified from when it last checked them. If you kill the process so that the lock is no longer there and the file is then changed by something else then just restoring the handle and lock later will leave the program in an invalid state. Or, more simple to understand, a network socket got to the state it was in by conversing with a server. Your restore tool would have to know how the socket got to the state it’s in—might be impossible with e.g. TLS – binki – 2016-06-30T20:27:22.793

Answers

2

I do this using VirtualBox from Sun for separating projects. It's also handy because you can take snapshots.

The drawback is you need to put an entire OS on there.

Incognito

Posted 2010-06-11T15:19:13.183

Reputation: 524

3

Yeah - I use VirtualBox for OS level snapshots, that's where i got the idea for an application level snapshot. It seems like there is something like this for Linux http://www.linux.org/apps/AppId_2488.html

However I think the problem is going to be open file handles and such, which make this a non-trivial problem.

– Sijin – 2010-06-11T17:51:44.843

0

ProcessExplorer from MS Sysinternals let you Suspend a process. does this help / do the job ?

user8228

Posted 2010-06-11T15:19:13.183

Reputation:

1@Breakthrough but if the process is suspended, it will give up memory (as other programs utilize memory they’ll cause this one to be paged out) without ever trying to reclaim it until you resume it. This is really the closest/safest way to get what you want—a swapped out suspended program basically is a safely stored snapshot of it, just one that is lost on reboot. – binki – 2016-06-30T20:30:19.387

5Unfortunately not... I wanted to take the process out of memory in order to free it up, not simply pause the application. Although this IS a very useful program for CPU intensive applications that you may need to pause! – Breakthrough – 2010-08-08T15:39:51.977

Suspending a process effectively freezes all other processes that happen to send some windows messages to it. It so happens that some processes do like to send messages to other processes, and some processes like to be targets for such broadcasts. So, suspending some processes is harmless, but for other cases it will interfere Your work with the computer. And one more thing. Some processes, after being resumed from long-lasting suspend, will freeze and take all your CPU to make up for all the lost time computing something very smart :P – Roland Pihlakas – 2013-05-17T15:51:25.103

There is also a pssuspend command line utility from MS Sysinternals. You can find it over there: http://technet.microsoft.com/en-us/sysinternals/bb897540. It is part of a PsTools package: http://technet.microsoft.com/en-us/sysinternals/bb896649 where You can also find for example a pskill tool, which is for example rather handy after resuming a process and it happens to get way too excited.

– Roland Pihlakas – 2013-05-17T15:54:06.093

-1

You can use WinDbg (Microsoft tool) to create a dump of the current state of a windows machine. Usually this is used to analyse problems, but maybe it could serve your needs as well. Search for keywords WinDbg and dump for further information, maybe there is even an option to dump only single processes.

Simon D.

Posted 2010-06-11T15:19:13.183

Reputation: 119

The dump file can’t be used to restore the process. – user2284570 – 2016-06-11T12:49:41.557