Hacker News new | ask | show | jobs
by ac2u 1040 days ago
> Maybe I can learn something here. From my understanding, the RAM image moves completely to the swap space, since the RAM memory is shut down (cleared)

I think your understanding is broadly correct. My point was centred on the nuance that the primary purpose of swap space is for the OS to move less frequently used parts of virtual memory to disk to allow more recently/frequently used virtual memory to occupy the physical RAM.

So theoretically, if you wanted to implement hibernation on top of such a system, you wouldn't need the OS to have swapping enabled. (Although from your examples, practically, in some cases at least you do)

Without swap space, the OS would still use virtual memory addressing and allocation, but it would only be translatable to physical addresses in RAM, and exhaustion of RAM would lead to the OS out of memory killer to start killing processes to free RAM up.

But you could still write a hibernation program to take everything in memory and write it to disk and restore it later even if you're not using the OS swap capability to provide programs with the illusion of more memory to use than RAM allows.