Patrick Desjardins Blog
Patrick Desjardins picture from a conference

Microsoft .Net 4.5 Garbage collector

Posted on: 2012-07-24

Microsoft have been working on the garbage collector since version 1 of the .Net framework. Nevertheless, since Framework 4, they have increased their effort to make this one more efficient. The version 4.5 (still in RC version at this moment), go a step further with a garbage collector that run concurrently from the user thread. This result to shorter time to recycle memory for large application. The new garbage collector is called "background server garbage collection".

Heap balancing Another improvement is that now, the garbage collector heap is balanced (small and large object). That mean that if a thread is using a lot of resource while others thread are not, the charge will be distributed evenly on all threads' heap. This will reduce the time before cleaning memory.

Scheduler A third improvement concern the time when the garbage collector can recycle its memory. It's possible to activate a mode "SustainedLowLatency" which will let you set a schedule when it's more appropriate to recycle memory. This let you have monster memory computer that will recycle only in a time frame or with exception within if the server run low in memory.

Large memory allocation Also, it's now possible with Microsoft Framework 4.5 to have large memory allocated without having the "OutOMemoryException". Before, any allocation over 2gb would raise an out of memory exception. Now, if the physical machine have more than 2gb, than you can have more than 2gb memory allocation.