Why is windows 10 compressing memory when I have plenty available?

(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.


Solution 1:

If I wanted to be snarky the answer to your question would be "because of One Microsoft Way", which seems to be their philosophy, not just their corporate HQ address in Redmond.

In short, Microsoft developers believe that they know best how our computers should be configured and used, and they will stop at nothing to force their "one size fits all" choices to all of us.

Memory compression is a perfect example of this.

I have a workstation with 64 GB of RAM and a 1 TB NVMe SSD and I am using a 3D application which uses a lot of RAM for assets. When memory compression is enabled, said 3D application is notably slower when loading those assets, its UI is less responsive, and it takes longer to start rendering because the OS has to decompress the data it just compressed before it can be sent to video RAM.

Yet even on systems with large amounts of RAM and fast SSD drives such as mine, memory compression not only defaults to enabled, but if you dare disable it, it will be re-enabled after each Windows 10 feature upgrade (I had it disabled, and upgrading to Windows 10 20H2 enabled it again).

So the real reason why memory compression is enabled in my opinion is the arrogance and ignorance of people working at Microsoft.

Solution 2:

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