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

SQL 2008 Developer Laptop Install 2

10. October 2008

So there was one hitch in the get-along.  For whatever reason, the install I just posted about wouldn't allow my network account to login.  So, I had to add that account in the Security folder after logging into SQL Mgmt Studio as 'sa'.  Sheesh!  I did set Mixed Mode authentication on.  Anyhow, the good thing is that now I can use (local) and integrated security=true in my connection strings.

SQL 2008 Developer Laptop Install

10. October 2008

I get to work with SQL 2008!  So, the laptop I was given for work already had SQL 2005 Express installed as the default instance.  Why on Earth that was there, I don't know.  While there is probably a better way to change that during the SQL 2008 install, I opted to remove it completely.  So, with a lappy toppy clean of all SQL programs, I installed SQL 2008!  Awesome stuff.  Most of the install steps are intuitive.  The one thing I always like to do is install my SQL server as the default instance and turn on mixed mode authentication.  The other two things I ran accross during the install were the install wizard screen for setting a user account to the various SQL services, and setting the path for all the data folders.  This seemed like a new feature that the SQL 2005 installer didn't have.  Although I'm sure you could get in and change all the SQL 2005 services to run under specific user accounts if you wanted to.  I decided to look for guidance on th eweb and found the following step by step install for SQL 2008 RC0.  Which is still good in the full release.

http://sqlblog.com/blogs/andy_leonard/archive/2008/07/15/installing-sql-server-2008-rc0.aspx

So, under that guidance, I set up a new user account, put it in the Admin group, and setup a new Data folder at the root of C.  Then because I fear the unknown, I went ahead and set security on the folder to full control for the new user account and for the Network Authority/Local Service account.  What the heck, right?  I would not recommend that exact setup on a production server, of course.  The install wizard prompted for the Data folder path so I replaced the "Program Files/Microsoft SQL Server" part with "Data".  This is an install I can feel all warm and fuzzy about.  Now let's see if I hit any roadblocks later.  :)

Silverlight and WCF Error Handling Woes

8. October 2008

There is a limitation in using WCF with Silverlight when it comes to handing errors during method calls.  Receiving SOAP faults is not supported in Silverlight 2.
 
Silverlight "doesn't know what to do" with System.ServiceModel.FaultException. If it did, we could pass the exception object back and the client could work with a typed object.

The solution is to create our own object and pass it back. I've read about this being done as a serializable object with limited data, or as an out parameter in the WCF service methods, or even as a field of the custom type in a domain object.

Here are some links to that information:
http://www.atrevido.net/blog/CommentView,guid,ffa70c25-0c78-474b-8d60-10a693ffc407.aspx
http://silverlight.net/forums/t/18885.aspx
http://silverlight.net/forums/p/17944/60019.aspx#60019

Silverlight