0

Why have one file, the swap file, with 2 purposes:

  • a swap file that serves the purpose for both providing some extra memory for apps (swap)
  • and also for storing the state of the entire system (suspend-to-disk/hibernation)?

In Windows, there appears separate file for each purpose:

  • Swap: For swapfile.sys for Windows 10 (pagefile.sys does the same job for older versions) and
  • hiberfil.sys is for the image of the system state in RAM for when the system is hibernated.

Wouldn't that be easier for decision making as to what size of swap to use (and what size needed for hibernation)?

Also, why would a file the size of all the RAM be needed for hibernation, if only one app is running consuming, for example, 1Gb out of 32Gb?

Question based on the discussion around the swap size decision making process here: What should my swap size be if I have 32GB of RAM? [closed]

  • 3
    Possibly the prime advantage of using swap is it wastes less disk space, prime disadvantage is the % of swap in use when hibernate is started can't be used for hibernate (already in use) so is the swap space left sufficient. I think windows has decided it's easier to waste space, rather than try & explain you need variable sized swap in use + ram size to have hibernate work (let alone the calculations required to work out the swap size used by apps – guiverc Aug 31 '18 at 22:42
  • It seems to me that the scenario where hibernation/suspend-to-disk needs considering as part of the swap size decision is in notebooks/laptops/tablets, where hibernating is a very useful facility for conserving battery charge, thereby extending the time before having to access a power source. And on that basis, in a desktop workstation example, the need for hibernation is therefore less, assuming a mains power source is constant. Perhaps with the exception of setups that are not powered from a national grid. – therobyouknow Aug 31 '18 at 23:07
  • Personally I think the device is irrelevant (the devs would disagree, hardware is a huge problem with hibernate currently because of the huge variation of devices running Ubuntu and subsequent issues) and i see it only as a math issue (calculating the size required for max.swap.used + memory). – guiverc Aug 31 '18 at 23:15
  • 1
    Actually you don't need your RAM size as swap space to be able to hibernate nowadays. You just need enough free space in your swap to fit all currently used memory in. However, hibernating to swap file still isn't really well supported (or at all?), only to swap partition. – Byte Commander Aug 31 '18 at 23:21
  • See duplicate: why it's done that way is it's more efficient to have one file use both purposes. Why Windows does it differently is because it's geared towards "easy" not "efficient" and why Ubuntu 18.04 runs on 10-year old computers and Windows 10 does not. – Fabby Sep 01 '18 at 15:51

0 Answers0