As a Silverlight developer one of my favorite tools besides Visual Studio is WinDbg. The native debugger has an extension for silverlight that helps you find memory leaks by showing you why your objects stick in memory.
If you want to know more on how to use it, dont miss Tess Ferrandez's blog ("If broken it is, fix it you should"). Also helpful (and full of further links) was David Ansons blogpost.
One day I found that all the objects I was searching for have been removed from memory. I almost thought that it was donut time, but then I noticed that memory was still slightly increasing over time.
The sos-extension for WinDbg offers a command called !DumpHeap -stat which dumps out all the objects on the managed heap. To find my leak I decided to take a dump, do something with my app, take a second dump and then compare the two dumps to see which new objects had been created.
To be able to compare the two dumps effectivly I wrote a small tool. Simply copy the dump from WinDbg via <Ctrl>+C and click on the "Paste" button above the corresponding textbox. Pasting the text directly to the textbox using <Ctrl>+V did not work for me, the text was chopped of. Dont know why, so I added the copy button. As soon as you copy the second dump to the second window, the text input is converted into a joined dataset and the comparrison result is shown in the lower pane.
The tool also calculates the "increasement factor" and colorizes the new count green or red depending on wether the number of objects increased or decreased (or is the same).
You can download the code here. The code is provided "as is" with no warrenties. Have fun!
Keine Kommentare:
Kommentar veröffentlichen