Enterprise Library Test Guide - Willy .Net
Enterprise Library Test Guide - Willy .Net
Enterprise Library Test Guide - Willy .Net
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Test</strong>ing for Performance and Scalability 237<br />
HashProviderFactory factory = new HashProviderFactory();<br />
IHashProvider hashProvider = factory.Create("hashprovider");<br />
hashProvider.CreateHash(b);<br />
System.GC.Collect();<br />
}<br />
Next, run the test again until the performance counters register the suspicious behavior.<br />
You can now use WinDbg to find and troubleshoot the memory leak.<br />
<br />
To use WinDbg<br />
1. On the taskbar, click Start, point to All Programs, point to Debugging Tools for<br />
Windows, and then click WinDbg. WinDbg starts.<br />
2. Because ASP.NET hosts the application block, you must attach the debugger to<br />
w3wp.exe. On the File menu, click Attach to Process. The Attach to Process list<br />
box appears. Click the By Executable option button. Click w3wp.exe. Click OK.<br />
After performing these steps, load the SOS extension to WinDbg. Open a command<br />
window in the debugger and type:<br />
!loadby sos mscorwks<br />
Next, look at the heap. Type:<br />
!dumpheap -stat<br />
This command reports all the managed objects that are currently in the heap, sorted<br />
by number of allocations and size. The MT column, where MT stands for Method<br />
Table, lists the pointers to the tables that describe the objects. The Count column lists<br />
the number of objects that exist in the heap for each type of object. The TotalSize column<br />
lists the amount of memory that is being used by any one type of object. The last<br />
column is the fully typed name of the object.<br />
MT Count TotalSize Class Name<br />
029b0800 11502 138024 Microsoft.Practices.<strong>Enterprise</strong><strong>Library</strong>.<br />
Caching.Expirations.NeverExpired<br />
79124670 193 229708 System.Char[]<br />
79124228 12721 340908 System.Object[]<br />
029b06d4 11501 460040 Microsoft.Practices.<strong>Enterprise</strong><strong>Library</strong>.Caching.<br />
CacheItem<br />
790fa3e0 20210000 93908800 System.String<br />
791242ec 140 14656992 System.Collections.Hashtable+bucket[]<br />
The suspicious entries have the largest counts and the largest sizes.<br />
Assume that the number of System.String objects appears suspicious. The memory<br />
dump says that there are 20210000 of those objects. This appears too high.<br />
You need to look at MT location 790fa3e0. Type:<br />
!dumpheap -mt 790fa3e0