Swap and hibernation
- by maaartinus
I saw a lot of recommendations claiming that for hibernation the swap partition/file must be at least as large as the main memory. This makes no sense to me. Lets assume I have 8 GB of main memory and 8 GB swap area and want to hibernate:
case 1: I'm using 4 GB of virtual memory - 8 GB of swap is unnecessarily large.
case 2: I'm using 8 GB of virtual memory - 8 GB of swap is just right.
case 3: I'm using 12 GB of virtual memory - 8 GB of swap is too small.
The outcome is: A swap area of size equal to the memory size is sufficient for hibernate IFF it doesn't get used for swapping at all. So what is the reason behind the claim that you need at least as much swap area as main memory for hibernate to work?
I know that virtual memory gets used for caching too, and that the cache may be simply discarded, but what happens to hibernation if a program allocates 12 GB of virtual memory (given the above memory and swap sizes)?