To Null or Not to Null

GC Myth: setting an object’s reference to null will force the GC to collect it right away.GC Truth: setting an object’s reference to null will sometimes allow the GC to collect it sooner. As much as you may want to, you can’t guarantee the GC will collect what you want, when you want it to….


Part 2 in Maoni’s Using GC Efficiently

Maoni posted Part 2 to Using the GC Efficiently.  A very in-depth article about Server, Workstation and Concurrent GC.  Check it out.


Dispose Dos and Don’ts

Due to the positive response on my previous entry on Dispose, I thought I’d write another, this time on what one should and shouldn’t do with a Dispose method. Dispose should contain code to release any unmanaged resources associated with the object’s instance. For example, any handles should be released, database connections closed, etc. This…


Demystifying Dispose

One commonly misunderstood feature is the relationship between disposable objects (Objects that implement the IDisposable interface) and the GC.  I know there are a lot of online resources about patterns and best practices but there is still a lot of confusion.  I remember going to a Dev Lab to answer some questions by Whidbey early…


GCHandles, Boxing and Heap Corruption

A GCHandle is a struct used to hold onto a managed object to be used by unmanaged code.  With a GCHandle you can (among other things): Prevent an object from being garbage collected if unmanaged code has the only live reference to it Pin an object in memory, so it won’t be relocated in memory…


A Few Good GC Links

I keep a GC folder in my Favorites full of links to articles and blog posts about the .NET GC.  I thought it would be a good idea to consolidate them all into one blog post, for handy reference.  These are the articles I most often post as answers to questions on public newsgroups. If you…


Server GC Misconceptions

One of the most common “bugs” I read about on the Microsoft public newsgoups is the fact that the runtime does not automatically choose Server GC mode on a multi-proc machine, or server OS. If the server OS is running on a single-proc machine then the runtime will have to load the Workstation GC, since…


Server, Workstation and Concurrent GC

One common question I see asked is the differences between server and workstation GC, and how Concurrent GC fits in. Server GC is only available on multi-proc machines. It creates one GC heap (and thus one GC thread) for each processor, which are collected in parallel. This GC mode maximizes throughput (number of requests per…


A New GC Blog

Hi!  My name is Chris Lyon, and I’m a tester for the .NET Garbage Collector.  The GC is one of the least-understood components of the CLR, and I hope to try to help our customers better understand it. Topics I hope to cover: General overview of how the GC works Finalization GC-related APIs (System.GC, System.Weakreference,…