Windows 8 / Windows Server 2012: The New Swap File

Windows 8 / Windows Server 2012: The New Swap File

  • Comments 7
  • Likes

Hello AskPerf! Welcome to day 7 of our Launch Series.  Today we are going to talk about the new Swapfile introduced in Windows 8.  You may ask, “Why do we need another virtual page file?”  Well, with the introduction of the Modern App, we needed a way to manage their memory outside of the traditional Virtual Memory/Pagefile method.  With that, the “%SystemDrive%\swapfile.sys” was born.  To view this file (hidden by default), you can go to View | Options | Change folder and search options | View tab.  In the Advanced settings section, scroll down and uncheck “Hide protected operating system files”, then click Apply, OK.

Swapfile.sys on the %SystemDrive%


Swapfile.sys and it’s interaction with the Memory Manager

Windows 8 can efficiently write the whole (private) working set of a suspended Modern app to disk in order to gain additional memory when the system detects pressure.  This process is analogous to hibernating a specific app, and then resuming it when the user switches back to the app.  In this case, Windows 8 takes advantage of the suspend/resume mechanism of Modern apps to empty or re-populate an app’s working set.

The sequence of events is described below:

1. The Process Lifetime Manager (PLM) detects memory pressure in the system and asks the Memory Manager (MM) to empty the working set of a specific process that houses a suspended Modern style app.



2. MM moves the pages of memory from the working set of the app to the operating system’s modified page list (which is a list of memory whose contents are to be written out to disk before being reused).



3. The working set pages on the modified page list are written out asynchronously, as dictated by the usual MM policies (written out opportunistically in the background, writes triggered when under memory pressure).



4. Even after the suspended app's working set is written to disk, the memory pages removed from a process are left intact on the operating system’s standby list.  This is a cache of useful pages of memory that can be repurposed for other apps, if necessary.  If these pages are immediately needed again by their original process, they are quickly moved back.


If a user switches back to the app while its working set pages are still in physical memory (on the modified page list or the standby list), the pages will be added back into the app’s process immediately.  If they are no longer available, Windows will read in the app’s working set from disk in an optimized manner.

With that, this concludes this post.  Tomorrow we will be going over the new Windows To Go option.  Have a great Day!

-AskPerf blog Team

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi, could you please explain why could not be pages of modern apps from the modified list written to the page file and swapfile is used instead? I understand the flow of pages being written out to disk but I'm still not getting the reason why not to the page file...Is there some more detailed documentation available? Thanks.

  • Will there be any new performance counter to track the swap file usage as we have counter to track page file usage?

  • Hi. Is there any way to move it to another partition ( HDD) ?

    Actually I use a dedicated partition for Pagefile, on a fast secondary drive, and I want to move this one to on that partition.

  • Hi, I'd like to say that I just want to disable this, what can I do to disable the swapfile.sys?

  • @Cristi-M:  I could not find a supported way to move "swapfile.sys" to another volume.  If I come across a way to do this, I will update this blog.

  • @Thomas King:  If you set Virtual Memory to "No paging file", the "swapfile.sys" along with "pagefile.sys" will be removed.  It does not look like you can disable "swapfile.sys" by itself.

  • I was just thinking, maybe it'd be somehow possible to change its config, and redirect to other drives by adding some registry keys. Just like when you create a dedicated dump file for example. I have not tested this yet, but it might be possible. On the other hand I have not found any swapfile related entry in registry, but would worth to try.