ASP.NET Tip: Understanding the caching of data in SOS

The sos that comes with the debugger, in the clr10 directory, has a lot of additional features and speed improvements for .NET 1.x troubleshooting.  One of the main ways it does this is by caching the data that is gathered from !DumpHeap -stat.

This is something important to remember if something happens where the command is run, but then something happens so that the cache isn't fully correct.  For example, if you are opening a dump on a remote share and some network issue happens, the cache will only be a partial cache.  If you try to run any commands that depend on that cache, they will only give partial output since the cache isn't complete.

The only way to resolve this is to unload the debugger extension (SOS) and reload it.  Then the cache will be recreated.

One other point of note along these lines.  If you are debugging a live process, it does not cache the data.  This is because normally you will run a command, let the process run some, and then run it again.  You don't want stale data when you re-run the commands.

One side-note, if you run !DumpHeap -stat a second time against a live process, you will see an additional column of output.  This is showing you the change from the last time the command was run.  This can be helpful to quickly see how much things have changed.