Welcome to MSDN Blogs Sign in | Join | Help

How to enable CLR Server GC?

This is one of the mostly asked questions about CLR GC.

CLR's GC has two modes: Server GC and WorkStation GC. The difference is discussed briefly in Gregor Noriski's MSDN article about writing high performance managed application(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/highperfmanagedapps.asp).

In .Net framework 1.0 and 1.1, the only supported way to enable server GC is going through CLR's hosting API. Steven Pratschner provided a sample in a newsgroup post: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&frame=right&th=8d37b7b7c04b7609&seekm=O6jAptPPDHA.2284%40cpmsftngxa06.phx.gbl#link2

In Whidbey (.Net framework 2.0) and 1.1 Service Pack 1, CLR introduces a config file option to enable server GC. The syntax is following:

<Configuration>
    <runtime>
        <gcServer enabled=“true“ />
    </runtime>
</Configuration>

This can be put in app.config or machine.config. App.config is preferred so that it won't affect all the applications on the machine.

In .Net framework 1.1 you can check if Server GC is enabled by checking whether mscorwks.dll or mscorsvr.dll is loaded. If mscorsvr.dll is loaded, then Server GC is enabled.

In Whidbey mscorsvr.dll is merged into mscorwks.dll, so the above technique will not work. Instead, System.Environment.IsServerGC should be used to check against Server GC.

This config file should work with Whidbey Beta1 and .Net framework 1.1 SP1 Technical Preview. Both are available now.

Published Tuesday, July 13, 2004 7:42 PM by junfeng
Filed under:

Comments

# re: How to enable CLR Server GC?

Wednesday, July 14, 2004 10:59 AM by David M. Kean
Wouldn't the IsServerGC be better placed on System.GC class, as it applies to the Garbage Collector?

# Enabling CLR Server GC?

Tuesday, July 13, 2004 10:01 PM by Lockergnome's Web Developers
As one writer explains, one of the most common asked questions about CLR GC is: "How to enable CLR Server GC?" Well, here you will find out about a config file that allows you to accomplish this task. Short, but...

# Server GC と WorkStation GC の切替(.Net framework 1.1 SP1)

Wednesday, July 14, 2004 9:08 AM by 米田 Blog ( SQL Server MEMO )
Server GC ? WorkStation GC ???(.Net framework 1.1 SP1)

# re: How to enable CLR Server GC?

Thursday, July 15, 2004 7:08 AM by Junfeng Zhang
David,

This is a good question. The original thinking is that this describes the state of the system. We will evaluate your suggestion. Since Whidbey is still in beta1, we still have time to make a change.

# ASP.NET Architecture Internals

Wednesday, August 25, 2004 2:06 PM by MikeShaw's WebLog

# How To Tell Which GC Mode Your Application Is Using

Friday, February 04, 2005 5:05 PM by Chris Lyon's WebLog

# How To Tell Which GC Mode Your Application Is Using

Friday, March 18, 2005 4:59 PM by Chris Lyon's WebLog

# Waltzing Through the Parallel Extensions June CTP: Known Issues

Wednesday, June 11, 2008 3:43 AM by All Your Base Are Belong To Us

In the previous posts in this series, we have looked at a multitude of features provided by the PFX June

# Soci blog &raquo; Blog Archive &raquo; A t??bbsz??l?? sk??l??z??s neh??zs??gei

New Comments to this post are disabled
 
Page view tracker