Windows – Why is windows 10 compressing memory when I have plenty available

memory managementwindows 10

(EDIT: I have been asked to explain why my question is not a duplicate of this question. I thought the reason would be obvious from reading the two questions but to summarise: I don't have a memory leak. I know exactly what is using my memory. I am wanting to know why Windows is choosing to compress my memory (and hence use CPU cycles and render my system slow and unresponsive) when my system appears to have sufficient memory to store the entire application footprint in memory uncompressed.)

I do a lot of scientific/engineering computing simulation with bespoke and memory hungry applications. Perhaps not memory hungry in a 8tb supercomputer sense, but memory hungry in the 'more than word/email/youtube and even chrome' sense. Historically my worksets have occupied anywhere from 4-30 gb of RAM.

Since the anniversary update I have experienced significant performance issues with my machine, and while investigating I noticed that windows appears to be fairly aggressively compressing memory. For example, when opening a particular model I experience this:

enter image description here

Just to summarise the pertinent points from that screenshot:

  • 15388 MB of memory in use
  • 6855 MB of memory compressed
  • If uncompressed, this would use 16657 MB
  • 16.6 GB of memory free
  • 32 GB of memory total

In short: If I didn't compress, by my understanding my memory requirements would be 15388-6855+16657 = 25190 MB. This is less than my available memory.

I have very often noticed that during times of reduced responsiveness my CPU is burning cycles doing memory compression like so:
enter image description here

I know that the concept of memory usage is extremely nebulous because of features like shared pages, reserved memory, copy on write etc etc but to me this situation looks like I'm just wasting CPU cycles and system responsiveness unnecessarily. My desire would be to simply not perform any memory compression and instead use my available RAM.

My questions are:

  • Is there something I am misunderstanding that explains what Windows 10 is doing (because the current behaviour seems irrational)?
  • Has there been a change in the behaviour/policy of memory compression since the anniversary update? I ask because I have only started experiencing these performance issues since the update.
  • Is there a way to disable the memory compression? I have tried the technique described here without any luck.

Full disclosure: a version of this question was posted to the microsoft forum but only received canned replies, so I am reposting here.

Best Answer

Is there something I am misunderstanding that explains what Windows 10 is doing (because the current behaviour seems irrational)?

From a November 2020 benchmark on memory compression (highlighting is my own):

An important note [...] when enabling memory compression, page combining is also automatically enabled.

This explains the "irrational" behavior: I believe your may have been bitten by this unexpected choice of enabling two pretty different features (memory compression and memory combining) together. My guess is that you measurements were matching page combining — which also takes place during idle and requires relevant CPU consumption.

Has there been a change in the behaviour/policy of memory compression since the anniversary update? I ask because I have only started experiencing these performance issues since the update.

I believe so: a quick check with Windows 10 20H2 showed that enabling memory compression alone worked (via Enable-MMAgent PowerShell applet), without activating memory combining.

Is there a way to disable the memory compression? I have tried the technique described here without any luck.

The described technique uses shorthand commands (-mc instead of -MemoryCompression) which, while I've checked that no error is thrown, are not documented and, therefore, might not be advisable.

Please run the following in a PowerShell with Administrator privileges:

  1. Display current status for memory compression, page combining and more
Get-MMAgent
  1. Disable page combining (this would be my suggestion, if it's enabled/True)
Disable-MMAgent -PageCombining
  1. Disable memory compression also (if really wanted)
Disable-MMAgent -MemoryCompression
  1. Displaying current status (again, for confirmation/comparison)
Get-MMAgent
Related Question