Silverlight 2 Memory Leak Debugging

31. October 2008

Here is a list of Debugging tools for Windows 32 bit operating systems:

Download link for 32 bit installer: http://msdl.microsoft.com/download/symbols/debuggers/dbg_x86_6.9.3.113.msi

Debug Diagnostic Tool v1.1: http://www.microsoft.com/downloads/details.aspx?familyid=28BD5941-C458-46F1-B24D-F60151D875A3&displaylang=en Silverlight

Silverlight Developer Runtime: http://www.microsoft.com/silverlight/resources/tools.aspx

Walkthrough:

  1. Download and install from the above links
  2. Start your Silverlight 2 application – leave the application running (see step 11)
  3. Do something in your application that reproduces the memory leak issue.
  4. Run Debug Diagnostic Tool (from Programs menu)
  5. Go to the Processes tab to find the running Silverlight application process a. This should say iexplore.exe if the application is running in Internet Explorer
  6. Right click the process and choose “Create Full Userdump”
    a. This creates a dmp file that you will use later.
    b. The path is shown to you when it is completed in a message box (click ok to close the message box – does nothing)
  7. Run WinDbg from the Debugging Tools for Windows (x86) program group (from Programs menu)
  8. From the File menu, choose “Open Crash Dump” and select the .dmp file that was created earlier
  9. A window will open that says “Command” at the top
  10. There is a command arguments text box at the bottom. Type in the following commands and hit enter after each one:
    a. .sympath SRV*c:\websymbols*http://msdl.microsoft.com/download/symbols
    b. .reload
    c. .load C:\Program Files\Microsoft Silverlight\2.0.31005.0\sos.dll 
       i. Note the path here. It points to a file installed with the Silverlight Developer Runtime and the path should correspond to the version installed
    d. !address -summary 
       i. this will give you an overview of the memory usage
    e. !eeheap -gc 
       i. to examine the size of the .NET GC heaps
    f. !dumpheap –stat 
       i. to dump out all .net objects in a statistical fashion
    g. !dumpheap –mt 
       i. replace with a value from the first column presented in above step, e.g. !dumpheap -mt 0x04e476b4
    h. !dumpobj 
       i. Replace with a value from the first column presented in the above step, e.g. !dumpobj 0x059911fc
  11. Repeat from step 3 using the same Silverlight application process. Open a new instance of WinDbg to open a new dmp file. The dmp files represent snapshots in time. So, in this case a memory leak should show increasing and not decreasing memory at each dump.

Silverlight

Comments are closed