17

I today discovered that we can set the size of the hiberfil.sys using powercfg -H -size 100% command line tool. Ignoring the hard space you will get, what else will change if we set it to powercfg -H -size 50%? Does it limit max RAM usage to 50%? Will system doesn't hibernate if I we more than 50% of RAM?

20

I have found a Microsoft document regarding the hibernation file. What it tells us is that the contents of memory are compressed before being dumped to the hibernation file so most of the time setting a lower percentage size of the hibernation file is beneficial as less disk space is wasted.

Windows supports hibernation by copying the contents of memory to disk. The system compresses memory contents before preserving them on the disk, which reduces the required disk space to less than the total amount of physical memory on the system.

The correct syntax for the command appears to be:

PowerCfg.exe /HIBERNATE /SIZE 75

The document also states that if the hibernation file is too small then a "Stop Error" will occur and the codes will suggest how much you need to increase the hibernation file size by.

Doing this will not limit the amount of physical RAM available to your system.

As it is compressed then reducing the size of the file will not be problematic if you only rarely hit 100% of physical memory used and/or your memory is likely to contain data that is reasonably compressible which most of the time it should be.

From that document:

Windows reserves disk space for hibernate in the hibernation file, which is named Hiberfil.sys. For Windows 7, the default size of the hibernation file is equal to 75 percent of the total physical memory on the system. For example, on a computer that has 2 GB of RAM, the default hibernation file size is 1.5 GB.

In rare and extreme cases of memory use, including memory validation by a memory performance or test utility, hibernate can fail because the contents of memory cannot be compressed enough to fit within the size of the hibernation file.

I would give it a try at lower numbers but personally I wouldn't go as low as 50%. It might well be fine though and the worst that will happen is that hibernation will fail and you'll have to reboot normally and set the size to be a bit larger.

  • 2
    Thanks for answer. I don't know about the official one but both powercfg -H -size 100% and PowerCfg.exe /HIBERNATE /SIZE 75 works properly – user218521 Apr 26 '14 at 14:58
  • 1
    It looks like on Windows 10, the powercfg command no longer accepts a /SIZE argument — it's no longer documented at least, but no error is produced if you specify it. – martineau Jan 17 '16 at 16:15
  • I found the time for resuming from hibernation increased substantially when I lowered the percentage to 60% (Windows 7 SP1). Am I the only one? – deddebme Jan 24 '16 at 2:10
  • @martineau it is entirely possible that due to the hybrid shutdown in Windows the size of the hibernation file has become adaptive in a similar fashion as the swap file. I've not had a chance to investigate, except to see that my hibernation file is approximately 35% of my system RAM size, but I'm not surprised. – Mokubai Jan 25 '16 at 14:36
  • 1
    @intrepidis: I am fully aware of that. Did you know that if you just use powercfg /? you will be treated to a much longer list of all possible parameters. Which, if you look through them, you'll eventually (they're not in alphabetical order) see the entry for -HIBERNATE, -H and that besides -H <ON|OFF> it will also accepts a -H -Size <PercentSize> where -Size Specifies the desired hiberfile size in percentage of the total memory. The default size cannot be smaller than 50. This switch will also enable the hiberfile automatically. — which matches the linked MS documentation. – martineau Jul 4 '18 at 0:48
4

The syntax in Windows 10 is slightly different

PowerCfg /h[ibernate] off

will switch off the hibernation and removes the file C:\hiberfil.sys

PowerCfg /h[ibernate] on

Will switch the function back on and creates the file C:\hiberfil.sys of about the same size as available memory (a 16GiB RAM system creates a 15.9GiB sized hiberfil.sys)

PowerCfg /h[ibrnate] size 75

Will create a hiberfil.sys file or reduce its size to roughly 75% (12GiB)

PowerCfg /h size 100

Is in effect the same as switching the feature on

A size value greater than 100 results in a parameter error message, a size smaller than 40 set the effective size to 40%.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy