Monday, May 13, 2013

CLR Memory Diagnostics Released

Last week, Microsoft released the new CLR Memory Diagnostics (ClrMD) library, which is a set of APIs for programmatically inspecting a crash dump of a .NET program.

To start playing with it, you first need to add the Microsoft.Diagnostics.Runtime package from NuGet (be sure to select Include Prerelease, because it is a prerelease version):

Inline image 2

You can use ClrMD to analyze a crash dump from disk, or to attach to a live process. In both scenarios, you will need to use one of the static factory methods declared in the DataTarget class. To analyze a crash dump file from disk, start with the following code:

   const string pathToFile = @"C:\TestApplication.DMP";
   using (DataTarget dataTarget = DataTarget.LoadCrashDump(pathToFile))
   {
        // ...
   }

QR: Inline image 1