在以前的Windows版本中,您可能还记得很好的旧分页文件。当物理内存被过度使用并且它保存通常很长时间没有被访问的对象时使用它。那是pagefile.sys。接下来,我们在Windows中提供了休眠选项,可让您将内核和所有应用程序保存到硬盘驱动器,以便您可以比完全重新启动更快地启动计算机备份。那是hiberfile.sys。
在Windows 8/10中,事情变得更加复杂。pagefile.sys 一直都在,但 hiberfil.sys 只有在Windows中启用了快速启动时才会出现。什么是快速启动?它基本上允许Windows执行混合关机。这就是为什么Windows 8/10启动速度比以前版本的Windows快得多的原因。查看我之前的文章,该文章解释了 Windows 8 中的混合关机(what a hybrid shutdown is in Windows 8)。
为了使用默认开启的新混合关机功能,必须在Windows中启用休眠。如果休眠被禁用,您将没有 hiberfil.sys 文件,也无法使用快速启动选项。你可以在这里阅读我关于在 Windows 中启用休眠的(enabling hibernation in Windows)帖子。
现在有趣的是,当您启用快速启动(意味着启用了休眠)时,您的 hiberfil.sys 将占RAM的 75% 左右,而分页文件将占 25% 左右。这是因为 hiberfil.sys 包含Windows内核和设备驱动程序。仅当所有RAM仅在我们的系统中耗尽时才使用分页文件,并且在您实际运行Windows时使用。hiberfil.sys 仅用于引导过程。
如果您没有在Windows中启用休眠,您会看到页面文件现在的大小与您拥有的RAM量相同。(RAM)
在上面的屏幕截图中,我有一台 1 GB RAM且禁用快速启动的Windows机器。(Windows)现在我们了解了它的工作原理,让我们开始使用新的:swapfile.sys。那是什么呀?嗯,它基本上就像页面文件,但有不同的用途。
swapfile.sys 的主要原因之一是暂停和恢复Windows 应用商店(Windows Store)应用程序。那么为什么不直接使用分页文件来做到这一点呢?使用它是因为使用这种特殊类型的页面文件可以更有效地完成某些类型的分页操作。
这里有一个更清楚的解释。Windows 支持分页和交换。分页将保留很长时间未访问的项目,而交换保留最近从内存中取出的项目。pagingfile 中的项目可能很长一段时间都不会被再次访问,而 swapfile 中的项目可能会更快地被访问。
此外,分页在高端机器上非常有效,而交换在低端平板电脑和 PC 上更有效。每个分页文件对动态增长、空间预留、读/写策略等都有不同的要求。如果你有相同的分页文件,由于分页中使用的固定大小的页面和大块,它会很快变得碎片化用于交换。
从上面可以看出,swapfile.sys 的大小约为 16 MB。到目前为止,它用于商店应用程序,因为与传统的(Store)Windows程序相比,它们的分页需求不同。未来它可能还有其他用途,但微软(Microsoft)并未具体说明具体用途。
这就是这三个文件在Windows 8/10系统上的作用。请注意,可能会发生一些有趣且烦人的事情。如果您有 16 GB 的RAM并且在Windows中使用快速启动,这意味着您也将拥有一个 16 GB 的休眠文件!如果您在 SSD 上运行Windows ,(SSD)那(Windows)可能会占用您的大部分磁盘空间。
您可以使用以下命令在不禁用休眠的情况下减小Windows中休眠文件 (hiberfil.sys) 的大小:(Windows)
powercfg.exe /hibernate /size 50
这会将休眠文件的大小减少到RAM的 50%,而不是 100%。请注意,您不能将其降低超过 50%。但是,如果您拥有16GB 或 32GB 或更多的大量RAM ,则可以为自己节省不少空间。(RAM)
另一件事是您不必担心休眠文件会像以前的Windows版本那样变得太大。早些时候,休眠文件存储了内核、设备驱动程序和所有应用程序数据。现在没有应用程序数据,文件的大小保持不变,所以如果你有很多RAM,你可能不需要这么大的休眠文件。
希望(Hopefully)这能让您更清楚地了解 pagefile.sys、hiberfil.sys 和 swapfile.sys 文件在 Windows 8/10 上的工作方式。如果您有任何问题,请随时发表评论。享受!
HDG Explains – Swapfile.sys, Hiberfil.sys and Pagefile.sys in Windows
In previous versions of Windows, you probably remember the good оld paging file. It is used when physical memory becomes оver-сommitted and it holds objects that usually have not been accеssed in a long timе. That is pagefile.sys. Next, we had the hibernate option in Windows that let you save the kernel and all applications to your hard drive so that you could start your computer back up faster than doing a full reboot. That is hiberfile.sys.
In Windows 8/10, things get more complicated. The pagefile.sys is there all the time, but the hiberfil.sys is only there if you have fast startup enabled in Windows. What is fast startup? It basically allows Windows to perform a hybrid shutdown. This is why Windows 8/10 boots up so much faster than previous versions of Windows. Check out my previous post that explains what a hybrid shutdown is in Windows 8.
In order to use the new hybrid shutdown feature, which is turned on by default, hibernation has to be enabled in Windows. If hibernation is disabled, you won’t have a hiberfil.sys file and you won’t be able to use the fast startup option either. You can read my post here about enabling hibernation in Windows.
Now the interesting thing is that when you have fast startup enabled (meaning hibernation is enabled), then your hiberfil.sys will be about 75% of your RAM and the paging file will be around 25%. This is because the hiberfil.sys contains the Windows kernel and device drivers. The paging file is only used if all RAM is exhausted only our system and is used while you’re actually running Windows. The hiberfil.sys is only used for the boot process.
If you don’t have hibernation enabled in Windows, you’ll see that the paging file is now the same size as the amount of RAM you have.
In the above screenshot, I have a Windows machine with 1 GB of RAM and fast startup disabled. Now that we understand how that works, let’s get down to the new one: swapfile.sys. What the heck is that? Well, it’s basically like the paging file, but serves different purposes.
One of the main reasons for the swapfile.sys is to suspend and resume Windows Store apps. So why not just use the paging file instead to do that? It’s used because certain types of paging operations can be done more efficiently using this special type of pagefile.
Here’s a more clear explanation. Windows supports both paging and swapping. Paging will hold items that haven’t been accessed in a long time whereas swapping holds items that were recently taken out of memory. The items in pagingfile may not be accessed again for a long time whereas the items in swapfile might be accessed much sooner.
Also, paging is very effective on high-end machines whereas swapping is more effective on low-end tablets and PCs. Each paging file has different requirements for dynamic growth, space reservation, read/write policies, etc. If you were to have the same paging file, it would become fragmented very quickly because of the fixed-size pages used in paging and the big chunks used in swapping.
As you can see from above, the swapfile.sys is about 16 MB in size. As of now, it’s used for Store apps because of their different paging needs as compared to traditional Windows programs. There may be other uses too for it in the future, but Microsoft has not specified what exactly.
So that’s what those three files do on a Windows 8/10 system. Note that there are some interesting and annoying things that can happen. If you have 16 GB of RAM and are using fast startup in Windows, that means you’re going to have a 16 GB hibernation file too! If you’re running Windows on an SSD, that may be taking up a large portion of your disk space.
You can reduce the size of the hibernation file (hiberfil.sys) in Windows without disabling hibernation by using the following command:
powercfg.exe /hibernate /size 50
This will reduce the size of the hibernation file to 50% of RAM rather than 100%. Note that you cannot lower it any more than 50%. However, if you have a large amount of RAM like 16GB or 32GB or more, you can save yourself quite a bit of space.
The other thing is that you don’t need to worry about the hibernation file becoming too large like in previous versions of Windows. Earlier the hibernation file stored the kernel, device drivers and all application data. Now that there is no application data, the size of the file stays pretty constant, so if you have a lot of RAM, you probably don’t need a hibernation file that is so large anyway.
Hopefully, that gives you a clearer understanding of how the pagefile.sys, hiberfil.sys and swapfile.sys files work on Windows 8/10. If you have any questions, feel free to post a comment. Enjoy!