Workstation GC Vs Background GC

Workstation GC Vs Background GC

Well, there has been a confusion around the developer community on the differences between the Workstation GC which is by default recommended for standalone machines which targets one single CPU Core and the Background GC which provides multicore execution of Garbage Collections.

In general aspect first let us consider how the Workstation is different from the server.

A Workstation is generally used to provide throughput. There could be a single application running which could use multiple Threads, but the basic idea is to give precedence on the application engine rather than the memory.

On the other hand, Server applications are generally very very long running (for instance ASP.NET Applications) and are job specific, such that when a job needs to be performed, a CPU is assigned to it to perform the task, and once the Task is complete the Thread needs to return back to the Pool. Thus server needs continuous maintenance of its memory usage without hampering the peformance of the application.

Related Read:  LargeObjectHeapCompaction in .NET Garbage Collection

There are three types of GC available currently.

1. Concurrent GC

Concurrent GC maintains a dedicated thread to collect memory footprints. When the GC is performed, all the managed thread may continue to run. For responsive applications, it is recommended to use Concurrent GC as it can still allocate memory while GC is running.

To enable Concurrent GC try :

<configuration>
<runtime>
<gcServer enabled="false"/>
</runtime>
</configuration>

2. Background Workstation GC.

This type of GC is mainly recommended for a client application like Windows Forms or console applications which runs on a single processor. The Workstation GC is a single Thread running on the whole application and collect the whole memory heap at a time concurrently using a single Thread.

To enable workstation gc

<configuration>
<runtime>
<gcServer enabled="false"/>
</runtime>
</configuration>

3. Background Server GC.

This type of GC is ideal for multi-core processor. This kind of GC provides separate managed heap and GC Thread for each processor and can perform more than one GC in parallel. When the GC is performed, all the Threads pointing to the current Core gets suspended. For servers the Background GC is much more recommended.

To enable background GC:

<configuration>
<runtime>
<gcServer enabled=“true"/>
</runtime>
</configuration>

I hope this would help in understanding things better.

Let me know your thoughts.

Abhishek Sur

Abhishek Sur is a Microsoft MVP since year 2011. He is an architect in the .NET platform. He has profound theoretical insight and years of hands on experience in different .NET products and languages. He leads the Microsoft User Group in Kolkata named KolkataGeeks, and regularly organizes events and seminars in various places for spreading .NET awareness. He is associated with the Microsoft Insider list on WPF and C#, and is in constant touch with product group teams. He blogs at http://www.abhisheksur.com His Book : Visual Studio 2012 and .NET 4.5 Expert Development Cookbook. Follow Abhishek at Twitter : @abhi2434

2 Comments to “Workstation GC Vs Background GC”

  1. Bhuvan

    Hi Abishek

    Is the configuration is same for Concurrent GC and workstation GC ? Will you please provide us any example on this if possible?

  2. Abhishek Sur Author

    Ohh sorry, Its exactly not.

    Actually Concurrent GC can be applied on either Workstation GC or Server GC. When Concurrent flag is turned off, it will be truely background, that means it wont stop the EE while collecting. Workstation will indicate whether finalizer is single thread or one for every core.

    Here is the configuration for Concurrency.

    There was a mistake in the post above.

    In fact, you can do like :

    Which means the GC will have a Single Thread and Single Heap for the entire process and will halt the execution engine during Garbage Collection and Heap Compaction.

    I am sorry for the mistake in the Post above.

Comments are closed.