If I'm understanding this correctly about garbage collection in .NET CLR, then GC occurs when space for a reference types allocation is needed but there is no more room on the managed heap. So does the managed heap have a limit as to how big it will get? Thanks.
+1
A:
Yes, for 32-bit processes the virtual address space is limited to 2GB (more realistically around 1.5GB when you factor in all the CLR's overhead). The limit for 64-bit processes is 8TB.
This does not mean that the heap is 2GB at first, rather that the heap can grow up to that size. The CLR will allocate more memory as needed. The heap has different generations (numbered 0 through 2) and each of these generations has a threshold. It is the meeting of those respective thresholds that triggers garbage collection. As your application runs, these thresholds will be adjusted to best suit the performance needs of your application.
Andrew Hare
2009-07-10 17:20:12
So garbage collection will only occur after 2GB of memory has been used by the heap? It seems like garbage collection would never run for most applications then since that is a pretty large limit.
2009-07-10 17:23:25
Is there any way to monitor the size limits of each generation? I would really like a low-level way to monitor when a garbage collection occurs to further my understanding.
2009-07-10 17:32:49
You sure can! You can use perfmon - please see http://codebetter.com/blogs/raymond.lewallen/archive/2005/03/31/60938.aspx
Andrew Hare
2009-07-10 17:51:49