Chris Lyon's WebLog

Or How I Learned To Stop Worrying And Love The GC

  • Chris Lyon's WebLog

    Demystifying Dispose

    • 36 Comments
    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...
  • Chris Lyon's WebLog

    New In Orcas Part 3: GC Latency Modes

    • 7 Comments
    As you may know, there are different GC modes to choose from depending on the type of application you’re using: Server GC, Workstation GC, and Concurrent GC ( more info ). These settings are process-wide, set at the beginning of the process. Once the...
  • Chris Lyon's WebLog

    Dispose Dos and Don'ts

    • 19 Comments
    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...
  • Chris Lyon's WebLog

    Server, Workstation and Concurrent GC

    • 29 Comments
    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...
  • Chris Lyon's WebLog

    A Few Good GC Links

    • 7 Comments
    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...
  • Chris Lyon's WebLog

    The Truth About GCHandles

    • 6 Comments
    I've heard several people asking why GCHandle doesn't implement IDisposable, considering it wraps an unmanaged resource (a handle) and needs to be explicitly freed (using GCHandle.Free()). Before I explain the reason, I want to give a little background...
  • Chris Lyon's WebLog

    GCHandles, Boxing and Heap Corruption

    • 10 Comments
    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...
  • Chris Lyon's WebLog

    To Null or Not to Null

    • 13 Comments
    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...
  • Chris Lyon's WebLog

    Server GC Misconceptions

    • 7 Comments
    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...
  • Chris Lyon's WebLog

    How To Tell Which GC Mode Your Application Is Using

    • 8 Comments
    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...
  • Chris Lyon's WebLog

    New In Orcas Part 2: GC Collection Modes

    • 5 Comments
    In Orcas we’ve added an overload to System.GC.Collect(): void System.GC.Collect(int generation, System.GCCollectionMode mode) Where generation is the highest generation to collect (from 0 to System.GC.MaxGeneration) and mode can be: Default...
  • Chris Lyon's WebLog

    Object Resurrection

    • 3 Comments
    I’m sure many of you have heard the term “object resurrection” with respect to the GC. It’s an interesting (but not very useful) way to illustrate object lifetimes and the role of finalization versus garbage collection. Basically, it’s a way to reference...
  • Chris Lyon's WebLog

    Why You Shouldn’t Rely On WeakReference.IsAlive

    • 5 Comments
    The WeakReference class has the property IsAlive. The problem with it, is that you can only trust it if it returns false. While a WeakReference points to an object that is either live (reachable), or garbage (unreachable) that has not yet been collected...
  • Chris Lyon's WebLog

    Brian Talks About SafeHandles

    • 0 Comments
    A great post on the BCL Team Blog by Brian Grunkmeyer about SafeHandles . He explains in-depth the topic I brought up ago a few posts ago about mitigating race conditions with the finalizer. Definitely worth a read.
  • Chris Lyon's WebLog

    Part 2 in Maoni's Using GC Efficiently

    • 0 Comments
    Maoni posted Part 2 to Using the GC Efficiently. A very in-depth article about Server, Workstation and Concurrent GC. Check it out.
  • Chris Lyon's WebLog

    New Dispose Guidelines

    • 0 Comments
    Joe Duffy has posted the revised Dispose, Finalization, and Resource Management Design Guideline . It's a great (and long) read. Check it out!
  • Chris Lyon's WebLog

    When GC.KeepAlive Doesn’t

    • 6 Comments
    The purpose of GC.KeepAlive(Object) is to tell the GC not to collect an object until a certain point. For example: class MyObject { ~MyObject() { Console.WriteLine(“MyObject Finalized”); } public static void Main() { MyObject obj = new MyObject...
  • Chris Lyon's WebLog

    WeakReferences And Tracking Resurrection

    • 3 Comments
    The WeakReference class has two public constructors. public WeakReference(Object target) public WeakReference(Object target, bool trackResurrection) The first parameter is pretty obvious. It’s the object you want the WeakReference to reference...
  • Chris Lyon's WebLog

    A New GC Blog

    • 6 Comments
    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...
  • Chris Lyon's WebLog

    New In Orcas Part 1: What we’ve been doing

    • 1 Comments
    The Orcas March CTP is out, and what does that mean for the Garbage Collector? The GC team has been concentrating on three areas for this release: Bug fixes. For Orcas, we’ve fixed several premature Out of Memory bugs, improved stability in certain...
  • Chris Lyon's WebLog

    The GC Test Team is Hiring!

    • 1 Comments
    Tired of the same old “garbage”? Do you want to be the tester for one of the most challenging technical areas of the Common Language Runtime (CLR) and work with the industry’s top developers, architects, and distinguished engineers? The CLR team is looking...
Page 1 of 1 (21 items)