TechExploring Windows Memory Management: To compress or not?

Exploring Windows Memory Management: To compress or not?

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

16 May 2024 07:48

Windows compresses the contents of RAM to fit more into it and avoid using the swap file, operating under the assumption that disk operations are always slower than processing. This leads to a preference for compression over paging.
The effectiveness of having a significant amount of RAM, automatic facilities, and paging becomes questionable in terms of performance when control over the system memory manager is very limited. Windows manages its memory settings in the Registry under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management," but these primarily adjust automatic adaptations and file sizes.

Limited capabilities

There is scant documentation for the FeatureSettings switch, which might influence the manager's behavior. Some options occasionally emerge to address issues like Meltdown and Spectre, yet options for controlling memory management are few:
- Disabling paging (removing the swap file)
- Disabling preload into memory (prefetch)
- Disabling prelaunch

- Combining memory pages

- Compression of used RAM

Disabling the swap file might not be advisable for several reasons, including compatibility. Similarly, disabling prefetch/preload mechanisms should be approached with caution; though they seem increasingly irrelevant with current computing practices, they can significantly affect the speed of starting applications.Disabling compression

Disabling memory compression appears to be the least invasive option, yet its impact on performance improvement may be negligible or hard to quantify. This differs from Linux systems, which allow for more direct control over the swap file usage through "swappiness." In Windows, alterations can only be made to the swap file's size, location, and presence.

Memory compression status can be checked in the Task Manager's Memory section, which shows the compressed amount - usually a low figure as RAM is inherently diverse and compresses poorly. However, lower disk speeds compared to processors and RAM can justify even modest improvements. To disable memory compression, one should use the MMAgent system collection in PowerShell. The following command stops the memory compression process, preventing further compression of content, and soon the reported amount of compressed memory drops to zero. If performance does not improve or worsens (a significant possibility with systems under 8GB of RAM), compression can be enabled again with the appropriate command.

Should disabling memory compression and the swap file not lead to an overall boost in performance despite ample RAM, it may indicate reaching the performance limit of the current hardware. In such cases, more advanced profiling is necessary, bearing in mind that a single number rarely describes a computer's overall performance adequately.
Related content