I posted previously about how to set the GC mode your application. So now that you’re running your app, how do you know it’s running in that GC mode?
If you’re using v1.0 or v1.1, the CLR loads a different dll based on which GC mode (mscorwks.dll for workstation, mscorsvr.dll for server). You can use tasklist.exe (ships with Windows XP and up) or tlist.exe (ships with Windows Debugging Tools) to determine which processes are using which dll. To list all the applications running with server GC:
tasklist /m mscorsvr.dll or tlist /m mscorsvr.dll
In Whidbey, we’ve condensed all the GC code into one library: mscorwks.dll. This means that all managed applications load mscorwks.dll, making the old method useless. Luckily we have two new ways to determine the GC mode:
System.Runtime.GCSettings.IsServerGC will return true if we’re in server GC mode, and false if in workstation. Note, this API is in a different location from Whidbey Beta 1.
The other way is using SOS, the debugger extension to WinDBG and Visual Studio. When your assembly is running, you can query the GC mode with:
One thing to note is that this will only return the GC mode and the number of heaps after the heap (or heaps) has been initialized.