TechUnlocking the secrets of Windows RAM management: A guide to optimization

Unlocking the secrets of Windows RAM management: A guide to optimization

How to disable memory compression?
How to disable memory compression?
Images source: © Pixabay

9:34 AM EDT, May 16, 2024

Windows optimizes RAM usage by compressing its contents, allowing more information to fit and reducing reliance on the slower swap file. This approach is predicated on processing compression being more efficient than engaging disk operations for page swapping.

However, when there's an abundance of RAM, automatic management features, including paging, may detract from system performance. Unfortunately, Windows offers limited control over its system memory manager. Settings in the Registry under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" primarily address automatic adjustments and file size parameters.

Limited Control Options

Documentation on the FeatureSettings switch, which might influence memory management behavior, is notably absent. Occasionally, some settings, such as Meltdown and Spectre, appear as remedies for vulnerabilities. The available methods for memory management adjustment are a few:

  • Eliminating the swap file
  • Turning off memory preload (prefetch)
  • Disabling prelaunch
  • Merging memory pages (page combining)
  • Compressing active RAM

Removing the swap file entirely might not be the best decision for compatibility reasons. Similarly, disabling prefetch or preload should be done cautiously, as these features, despite seeming redundancy, can significantly influence application launch times. However, their relevance is diminishing with the evolving nature of computer use today.

Considering the disabling of compression

Deactivating memory compression appears to be the least invasive option. Nevertheless, it's important to remember that any performance boosts from this action might be negligible or hard to quantify. This limitation mirrors the broader issue of restricted swap file management in Windows, contrasting to the more flexible "swappiness" function in Linux. In Windows, users can only modify the swap file's size, location, and presence.

Compression enabled
Compression enabled© Dobreprogramy | Kamil Dudek

One can look in the Task Manager's Memory section to check if memory compression is active. The amount of compressed memory is typically low since RAM naturally compresses poorly. However, given the slower speed of disks compared to processors and RAM, even small gains from compression can be warranted. Disabling memory compression involves using the MMAgent system collection in PowerShell. A specific command will stop the memory compression process, and any compressed content will not be recompressed. Shortly after, the reported amount of compressed memory should be reduced to zero. Compression can be re-enabled with a command if performance does not improve or worsens post-disabling (a significant possibility on systems with less than 8GB of RAM).

If turning off memory compression and the swap file doesn't lead to performance gains on systems with ample RAM, it may indicate reaching the hardware's performance ceiling. Thus, optimization efforts might need redirection toward more advanced profiling. Nonetheless, capturing a computer's performance with a singular metric remains challenging.

Related content