Sample Header Ad - 728x90

Is it possible to serialize a running program's memory image to disk, instead of closing it?

1 vote
1 answer
230 views
I recognize this is a stretch, but I have a shadow of a memory of a way to do it, and I'm hoping someone here will recognize what I'm talking about and help jog it. Traditional programs, both by terminal and GUI, have a starting sequence and a closing sequence of instructions, which can sometimes take some time to execute. Additionally, they may have other constraints, such as retrieving data from a database which may not always be available. A "memory image" of a program, I am defining as its footprint in RAM while running. That is, a one-to-one mapping of all memory allocated to the program. It is possible to image (and even mount the image of) a physical disk, to create an AppImage for an entire dependency structure, and to keep a virtual machine state (effectively an image) of the state of a virtual OS; so I may be wrong; but is it possible to save the memory state of a program (warts, inefficiency, and all) to a binary file? (One of my concerns is that some references kept by the image may change between boots, but this is technically a solvable problem and might not disqualify the idea.) If so, how would I go about doing this on a *nix system? It clearly isn't always (or even usually) an advantage, but I feel it bears investigation. To illustrate what I am trying to do: 1. Open Vim 2. Write a lengthy amount of text in Vim 3. Serialize Vim to disk without formally closing it 4. Wait several days 5. Deserialize instance of Vim from disk 6. Continue writing the same text So, save the state of the whole program, instead of just the file. One workaround I thought of is to run the program in a virtual instance, but this feels like it might typically be excessive.
Asked by Michael Macha (323 rep)
Oct 18, 2022, 11:39 PM
Last activity: Oct 19, 2022, 08:45 AM