What happen if we reduce the size of hiberfil.sys

17

6

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?

user218521

Posted 2014-04-26T09:41:28.797

Reputation:

2

the system will crash with this bucheck (http://msdn.microsoft.com/en-us/library/ff559341%28v=vs.85%29.aspx) when the used RAM is larger than the hibernation file can store

– magicandre1981 – 2014-04-26T14:38:39.810

Answers

21

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.

Mokubai

Posted 2014-04-26T09:41:28.797

Reputation: 64 434

1It 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 – 2016-01-17T16:15:07.367

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 – 2016-01-24T02:10:03.483

@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 – 2016-01-25T14:36:35.747

@deddebme: I haven't noticed any significant change on resume speed after using a powercfg -H -Size 60 size setting on my Win 7 Pro SP1. – martineau – 2016-01-25T16:22:18.087

@martineau You can see documentation for the size parameter by typing on the command line: powercfg /h /? – intrepidis – 2018-07-03T22:07:10.200

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 – 2018-07-04T00:48:14.947

2Thanks for answer. I don't know about the official one but both powercfg -H -size 100% and PowerCfg.exe /HIBERNATE /SIZE 75 works properly – None – 2014-04-26T14:58:50.897

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%.

user718960

Posted 2014-04-26T09:41:28.797

Reputation: 241