4

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)?

0

1 Answer 1

2

It's quite simple really,

When hibernating the system saves whatever is in RAM to the disk, and if there is not enough room in swap, the system will complain and not allow you to hibernate. To avoid this happening, it is best to have at least the same amount of swap space as your RAM. In most cases, you don't need any more than this, as the majority of applications almost never use enough RAM for swap to be under heavy usage.

However, if you have a small amount of RAM, or if you use a rather heavy application, you will probably want to double the size of your swap to accommodate the memory that needs to be written for hibernation.

3
  • That's OK, but with no amount of swap there's a guarantee that hibernate will succeed (it can be all taken as virtual memory), right?
    – maaartinus
    Mar 13, 2011 at 12:07
  • @maaartinus I'm not sure I understand what you're asking me in this comment? You should be able to hibernate if you follow the recommended setup, because applications won't be allowed to go over a certain level of memory (for stability reasons).
    – RolandiXor
    Mar 13, 2011 at 13:20
  • OK, I'll try it out.
    – maaartinus
    Mar 13, 2011 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .