PSSCor2: Object Inspection Commands, Part 2
In the previous installment, we’ve seen how PSSCor2 makes it easy to display the contents of a DateTime, of an IPAddress, of an XmlDocument, and of certain collection classes. Now we’ll take a look at some additional commands that inspect heap objects.
The !DumpField commands automates the process of displaying a particular object field (by field name). This is especially useful when combined with some looping constructs like .foreach to execute a script in the debugger session. In the following example, I have an Employee class that has an _id field, and I want to display all the IDs of all the employees currently present on the managed heap:
0:000> .foreach (emp {!dumpheap -type SimpleManagedApp.Employee -short}) {!DumpField -field _id emp}
2775
1771
2309
1170
2636
1819
Next, there are two specialized commands for analyzing DataTables: !DumpDataTables and !DumpColumnNames. The first is extremely useful when you want to see if there are any large DataTables consuming a significant amount of memory; the latter is useful for inspecting these specific tables and detecting what they are. For example:
0:003> !dumpdatatables
Loading the heap objects into our cache.
DataTable Rows Columns DataSet nextRowID ColumnCount
-----------------------------------------------------------------------------------------------
0x25fd6a0 0x25fda78 0x25fd928 0x25e145c 3 0
Total 1 DataTable objects
0:003> !dumpdatatables -size
*** Runs !ObjSize on each DataTable so this may take a while!
Loading the heap objects into our cache.
sizeof(025fd6a0) = 7,040 ( 0x1b80) bytes (System.Data.DataTable)
DataTable TotalSize Rows Columns DataSet nextRowID ColumnCount
-----------------------------------------------------------------------------------------------
0x25fd6a0 7,040 0x25fda78 0x25fd928 0x25e145c 3 0
Total 1 DataTable objects
0:003> !dumpcolumnnames 0x25fd6a0
Column Names for DataTable: 0x25fd6a0
author, book_Text
(This DataTable was created by loading a simple XML document into a DataSet.)
Similarly, there are numerous commands for inspecting the state of an ASP.NET application. Here’s some example output—I’m sure you’ll figure out these commands from context, and using the !help command:
0:018> !aspxpages
Going to dump the HttpContexts found in the heap.
Loading the heap objects into our cache.
HttpContext Timeout Completed Running ThreadId ReturnCode Verb RequestPath+QueryString
0x04f7715c 19200 Sec yes XXX 200 GET /Default.aspx
0x050fc398 110 Sec yes XXX 404 GET /favicon.ico
0x0514aaac 19200 Sec no 85 Sec 6 200 POST /Default.aspx
Total 3 HttpContext objects
0:018> !DumpASPNETCache -s
Going to dump the ASP.NET Cache.
Loading the heap objects into our cache.
Address MT Priority Create Time Expires Last Updated Key Class Name
051502a4 001a9148 Normal 08/23/2010 12:06:39 12/31/9999 23:59:59 0 MyKey System.String
050fda8c 0a951300 Normal 08/23/2010 12:06:39 12/31/9999 23:59:59 0 dmachine/webroot/1/favicon.ico System.Web.CachedPathData
050e1a94 0f8caeec Normal 08/23/2010 12:06:38 08/23/2010 12:07:39 08/23/2010 12:06:39 e1Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Triden System.Web.Mobile.MobileCapabilities
050e1a94 0f8caeec Normal 08/23/2010 12:06:38 12/31/9999 23:59:59 0 z-90014800 System.Web.Mobile.MobileCapabilities
050b3d4c 0f8c6bd0 Normal 08/23/2010 12:06:38 12/31/9999 23:59:59 08/23/2010 12:06:39 cdefault.aspx.cdcab7d2 System.Web.Compilation.BuildResultCompiledTemplateType
050af710 0044c774 Normal 08/23/2010 12:06:38 12/31/9999 23:59:59 08/23/2010 12:06:38 yapp_web_mrdimh5w System.Reflection.Assembly
04f95fb0 0ec031d4 Normal 08/23/2010 12:06:37 12/31/9999 23:59:59 08/23/2010 12:06:39 hc:\users\sasha\documents\visual studio 2010\Projects\SimpleManagedApp\MyWebApp\Default.aspx System.Web.Security.FileSecurityDescriptorWrapper
04f8fde0 0a951300 Normal 08/23/2010 12:06:37 12/31/9999 23:59:59 08/23/2010 12:06:39 dmachine/webroot/1/default.aspx System.Web.CachedPathData
04f50e84 0a951300 Normal 08/23/2010 12:06:36 12/31/9999 23:59:59 08/23/2010 12:06:39 dmachine/webroot/1 System.Web.CachedPathData
04f46184 0a951300 Normal 08/23/2010 12:06:36 12/31/9999 23:59:59 08/23/2010 12:06:39 dmachine/webroot System.Web.CachedPathData
04f38a10 0a951300 Normal 08/23/2010 12:06:36 12/31/9999 23:59:59 08/23/2010 12:06:39 dmachine System.Web.CachedPathData
Total 11 cache objects, Total size: 792
0:018> !DumpHttpRuntime -r
Going to dump the HttpRuntimes found in the heap.
Loading the heap objects into our cache.
HttpRuntime 0x04f2c9d8:
_shutdownInProgress: 0
_requestQueue:
RequestQueue 0x04f777c4:
_minExternFreeThreads: 704
_minLocalFreeThreads: 608
_appDomainAppPath: c:\users\sasha\documents\visual studio 2010\Projects\SimpleManagedApp\MyWebApp\
_appDomainAppId: f46e0782
_fcm:
Name: System.Web.FileChangesMonitor
MethodTable: 0a6dd350
EEClass: 0a76d8b0
Size: 60(0x3c) bytes
GC Generation: 1
Fields: […removed for brevity…]
_cacheInternal:
Name: System.Web.FileChangesMonitor
MethodTable: 0a6dd350
EEClass: 0a76d8b0
Size: 60(0x3c) bytes
GC Generation: 1
Fields: […removed for brevity…]
_isOnUNCShare: 0
_debuggingEnabled: 1
-----------------
Total 1 HttpRuntime objects
Additional commands in this category that you might find useful are !DumpRequestQueues, !DumpRequestTable, !DumpHistoryTable, !DumpBuckets, and !GetWorkItems. Some of them require rather delicate understanding of IIS internals.
Next time: Miscellaneous GC-heap-related commands.