New Silverlight SOS.DLL Command: !AnalyzeOOM
In the conclusion of my previous post on the Silverlight SOS.DLL, I’ve mentioned that some new commands (not present in the desktop CLR version) have been added.
The first command we’ll talk about is !AnalyzeOOM, which (as its name implies) analyzes an out of memory condition and explains what went wrong. There are various reasons for out of memory exceptions, and this command can help you to pinpoint exactly what went wrong.
I’ve written a simple Silverlight application that allocates 1MB byte arrays in a loop and keeps them referenced forever. After a few seconds the application crashes with an OutOfMemoryException. Running the command exposes the following:
0:005> !PrintException
Exception object: 03991ad4
Exception type: System.OutOfMemoryException
<snipped for clarity>
0:005> !AnalyzeOOM
Managed OOM occured after GC #17 (Requested to allocate 1048592 bytes)
Reason: Didn't have enough memory to commit
Observing the process’ virtual address space reveals the following (edited):
0:005> !VMStat
TYPE MINIMUM MAXIMUM AVERAGE
Free:
Large 1,032K 16,004K 5,898K
<snipped for clarity>
Hmm. The largest available block of virtual memory is less than 16MB (which is less than the smallest GC segment size). This is why the allocation is failing.