Memory Compression in Windows 10 Threshold 2

In this Ask the Admin, I’ll provide you with a quick rundown of the changes to memory management in Windows 10 Threshold 2, which is slated for release in November.

Most technical users of Windows are familiar with the concept of the page file, which allows Windows to swap memory out to disk, so that under low memory conditions, pages can be purged from physical memory and loaded back into RAM from disk at a later time. While this prevents Windows from running out of memory, loading pages into RAM can cause disk thrashing, which in turn negatively impacts performance.

In Windows 10 Threshold 2 or build 10525, Memory Manager compresses infrequently accessed pages, typically by 40 percent, while retaining them in a new compression store that’s held in physical RAM. If Memory Manager dictates that pages do need to be swapped out to disk, they are already considerably smaller in size, reducing the amount of disk I/O required during read/write operations.

Memory compression in Windows 10

Prior to build 10525, when Memory Manager decides that a page hasn’t been used in a while, it gets written to the modified page list and is then written to disk before being moved to the standby page list. The standby list caches pages that can be taken and used by other apps, but if the original process needs the page back straightaway, it can be reclaimed quickly — otherwise known as a soft fault. Hard faults occur when a page must be retrieved from disk because it’s been purged from RAM, which can be costly to overall system performance and responsiveness.

Memory compression in Windows 10 (Image Credit: Microsoft)
Memory compression in Windows 10 (Image Credit: Microsoft)

Windows 10 build 10525 introduces an additional stage to the process described above. Instead of being written to disk, trimmed pages belonging to a working set are moved to the modified list, are compressed and then moved to the system working set. Only when the availability of physical RAM runs critically low, Memory Manager writes pages to disk.

Pages are stored in compression stores, for which there is one for all legacy desktop apps and other non-UWP processes, and one for each Universal Windows Platform (UWP) app. Because compression stores are held in the system working set, the size of the system working set grows, as UWP apps are suspended.

When an app requires a memory page that’s been swapped out, if it is held in a compression store, Memory Manager decompresses it and returns it – known as a soft compression fault. Otherwise, a hard fault occurs, and the page is read from disk and decompressed.

Universal Windows Platform apps

UWP apps are swapped out in their entirety, not trimmed like legacy system apps and other processes. This is because when UWP apps are suspended, they are not in use and the pages used can be safely swapped out in their entirety. When a UWP app is resumed, the combination of sequentially reading the pages from disk back into physical RAM, and parallel decompression using multiple CPU cores, results in an extremely fast and efficient operation.

Improved performance for Windows 10

You may be reading this and thinking that these changes will only benefit low-memory systems. While it’s true that devices with limited amounts of RAM will benefit the most, the upcoming changes to Memory Manager will benefit all systems running Windows 10, by reducing RAM usage and page file I/O operations, which in turn will improve system responsiveness and the lifetime of solid-state disks.