Garbage collector is one real heavy task in a .NET application. And it becomes heavier when you are working withASP.NET application. ASP.NET applications run on the server and a lot of clients send requests to the server thus creating loads of objects, making the GC really work hard for cleaning up unwanted objects.
In .Net 4.5 server GC was introduced to overcome the above problem. In server GC there is one more thread created which runs in the background. This thread works in the background and keeps cleaning objects thus minimizing the load on the main GC thread. Due to double GC threads running, the main application threads are less suspended, thus increasing application throughput.
To enable server GC, we need to use the gcServer XML tag in the web.config and enable it to true.
<configuration>
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>
By Default it is disabled. As per the MSDN “There are only two garbage collection options, workstation or server. For single-processor computers, the default workstation garbage collection should be the fastest option. Either workstation or server can be used for two-processor computers. Server garbage collection should be the fastest option for more than two processors. Use the GCSettings.IsServerGC property to determine if server garbage collection is enabled.
In the .NET Framework 4 and earlier versions, concurrent garbage collection is not available when server garbage collection is enabled. Starting with the .NET Framework 4.5, server garbage collection is concurrent. To use non-concurrent server garbage collection, set the <gcServer> element to true and the <gcConcurrent> element to false
So if you’re using ASP.Net 4.5 and have a multi-core server, you should try turning on the Server Garbage Collection and do some profiling to see if it improves the performance of your site.
References
No comments:
Post a Comment