1

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.

0

1 Answer 1

3

Yes. CRIU is the acronym of the technology under Linux that allows that.

There's severe restrictions, though, that arise from the logical necessity of the files opened by the program being "frozen" not having changed, sockets still being there, and any external state being the same, or the loss of state at least being recoverable. Which effectively rules out X11 programs, and certainly didn't make curses/graphical tty utilizing programs easier to push through CRIU.

Where you find this very commonly is containerized server workloads - the whole file system is private anyways, and network connections are kind of common to be lost, so recovery from that is usually built into server software.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.