CLR Garbage Collector frequency and system memory

2019-08-04 19:10发布

问题:

I have a system with 300MB of physical memory available and 6 .NET processes. Each of them can jump from 100MB in idle to 500MB in stress when resources are available. I know that system specs have to be increased but I wonder whether GC will try to collect memory more often and try to keep processes memory allocation as small as possible? Does\how GC frequency depend on system memory available?

I'm using 2.0 runtime.

回答1:

Garbage collection indeed depends on the system memory. It's lazy. That means it will collect less often if there is enough free space anyway.

You can read up on the details here.

The most important sentence for you:

Garbage collection occurs when one of the following conditions is true:

  • The system has low physical memory.

If you have low overall memory, there will obviously be low free physical memory more often.