Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Experience using gcServer="true" to set garbage collector for .NET

Tags:

Has someone used a configuration enabling the garbage collector optimized for multi-processor machines using Aspnet.config with :

<gcServer enabled="true"/> <gcConcurrent enabled="true"/> 

Was there an improvement in the performance of your site?
Are any problems noticed?

like image 734
lsalamon Avatar asked Apr 27 '09 17:04

lsalamon


People also ask

How does the .NET garbage collector work?

The garbage collector (GC) manages the allocation and release of memory. The garbage collector serves as an automatic memory manager. When there isn't enough memory to allocate an object, the GC must collect and dispose of garbage memory to make memory available for new allocations.

What are the methods used in .NET framework for garbage collection?

. NET's garbage collector manages the allocation and release of memory for your application. Each time you create a new object, the common language runtime allocates memory for the object from the managed heap.

Does .NET have automatic garbage collection?

Automatic memory management is made possible by Garbage Collection in . NET Framework. When a class object is created at runtime, certain memory space is allocated to it in the heap memory.


2 Answers

First, Concurrent and Server are mutually exclusive options. See this blog post for some details on server GC misconceptions. However, ASP.NET, by default, hosts the server GC (see Scott Hanselman's discussion), so there will be no difference there.

I'd recommend sticking with server instead of concurrent for an ASP.NET website. For a user-mode application, the concurrent GC has been user responsiveness, since the server gc will cause "hangs".

I have used the server GC, and noticed significant improvements in certain situations.

The server mode GC does help user apps, though, if you're user application is working with huge memory pools, and getting highly fragmented.

like image 68
Reed Copsey Avatar answered Sep 24 '22 03:09

Reed Copsey


(very old question, I know, but I thought to add this anyway)

There's one major difference between Server GC and Concurrent GC: the Server GC has one thread per processor and suspends the threads on that processor when doing a collection, the server Concurrent GC thread runs in parallel with the other threads, i.e., no suspension. See this MSDN article for more info and more subtle differences.

Depending on the time a cycle takes, this can make a rather big difference in user responsiveness of your application, so choose wisely. In case of ASP.NET, which does not have a UI, Server GC is the better (and default) option.

like image 21
Abel Avatar answered Sep 21 '22 03:09

Abel