Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does concurrent garbage collection work with parallel computations?

In .NET 4 it is possible to enable concurrent GC.

Q1 How does it work with parallel computations: Parallel, Task, PLINQ etc?
Q2 As a software developer what shall I be aware of when working with concurrent GC?

like image 427
oleksii Avatar asked Jun 07 '11 19:06

oleksii


1 Answers

  1. The Concurrent GC will work fine with parallel computations. It runs inside of its own dedicated thread - so it's already handling working in concert with other threads. The runtime itself handles any synchronization required for you.
  2. In general, you shouldn't have to worry about this at all. The beauty of the GC is that you rarely have to worry about its implementation details. The only time I would worry about this is more if you profile and discover that a large amount of your processing time is spent in GC. However, this is not really specific to one form of GC, but rather overall profiling and memory usage in general.

That being said, in .NET 4, the new "Background GC" was added. There is a detailed post describing this here as well as this Channel 9 video.

like image 153
Reed Copsey Avatar answered Sep 21 '22 01:09

Reed Copsey