TechWindows Memory Management: Navigating the complexity of compression and paging

Windows Memory Management: Navigating the complexity of compression and paging

How to turn off memory compression?
How to turn off memory compression?
Images source: © Pixabay
Kamil J. Dudek

16 May 2024 11:37

Windows compresses the contents of RAM to fit more into it and avoid using the swap file. This approach is based on the premise that disk operations will always be slower than processing loads. Thus, compression is preferred over paging.

When there's a large amount of RAM, automatic facilities and paging might start to serve more as a performance bottleneck than a benefit. The control over the system memory manager is quite restricted. Windows stores its configuration in the Registry at "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", but the settings are mostly about automatic adjustments and file sizes.

Limited capabilities

The documentation for the FeatureSettings switch, which could potentially control the manager's behaviour, is not available. Occasionally, some enigmatic options appear as mitigations for security vulnerabilities like Meltdown and Spectre. The options for controlling memory management are limited to:

  • entirely disabling paging (removing the swap file)
  • disabling preload into memory (prefetch)
  • disabling prelaunch
  • combining memory pages (page combining)
  • compression of used RAM

Fully disabling the swap file is not recommended for various reasons, including compatibility issues. Similarly, caution is advised when disabling prefetch/preload mechanisms. Despite their seemingly diminishing relevance, they can significantly affect the speed at which applications launch, especially those that do not start in the background. This is indicative of the changing nature of computer work today.

Disabling compression

Disabling memory compression appears to be the least invasive option - but it's important to remember that the impact of this action on performance enhancement might be negligible or hard to predict. This difficulty arises from the inability to manage the use of the swap file in Windows - a feature that is readily adjustable in Linux systems under the term "swappiness". In Windows, we can only change the size, location, and presence of the swap file.

To check if memory compression is enabled, one can look in the Memory section of the Task Manager. The reported value of compressed memory is typically quite low since RAM is inherently diverse and compresses poorly. However, the lower speed of disks compared to the processor and RAM might justify even modest gains from compression. To disable memory compression, the following command in the PowerShell environment, using the MMAgent system collection, should be executed:

Executing this will stop the memory compression process. Previously compressed content and any new memory will not be compressed further. Shortly afterward, the reported amount of compressed memory will decrease to zero. If disabling compression does not improve performance or actually degrades it (a notable possibility on systems with less than 8GB of RAM), compression can be re-enabled with the appropriate command:

If turning off memory compression and the swap file does not enhance computer performance with a significant amount of RAM, it may indicate that the system has reached its performance ceiling with the current hardware. In such cases, further optimization may require more advanced profiling. It's often challenging to accurately measure a computer's performance with a single metric.

Related content