Success story and tips for debugging Win Forms
homologicus
Posts: 2
Gentlemen/Ladies, my compliments on a great product. I was debugging a leak in a Windows Forms application and the instance retention graph actually led me to a particular line of code! It wasn't even my code, and I was able to identify the line that caused the problem, just from working in ANTS. I have no idea how we would have identified the problem without it. It would have cost a fortune. ANTS paid for itself in just that single bug.
I have a few of these WinForms leaks under my belt now and thought I'd share my lessons learned:
* I know this is no great insight, but static events are the root of many managed leaks. Be very suspicious of them when debugging.
* When working in a WinForms application, watch objects of type System.Windows.Forms.PropertyStore. They are used heavily in the WinForms code and almost anything that you leak in WinForms will show as a large number of PropertyStore objects leaking. You can follow their retention graph up to the culprit in your code.
* You can really effectively narrow down your problem by varying your "steps to reproduce" and watching what happens in ANTS. I found a key clue by disabling an option in our application. I disabled the option, re-ran the steps and, no leak.
HTH somebody.
I have a few of these WinForms leaks under my belt now and thought I'd share my lessons learned:
* I know this is no great insight, but static events are the root of many managed leaks. Be very suspicious of them when debugging.
* When working in a WinForms application, watch objects of type System.Windows.Forms.PropertyStore. They are used heavily in the WinForms code and almost anything that you leak in WinForms will show as a large number of PropertyStore objects leaking. You can follow their retention graph up to the culprit in your code.
* You can really effectively narrow down your problem by varying your "steps to reproduce" and watching what happens in ANTS. I found a key clue by disabling an option in our application. I disabled the option, re-ran the steps and, no leak.
HTH somebody.
Tagged:
Comments
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
Thanks for your post.
You can get more information on this part of the process and related info in my links below.
https://documentation.red-gate.com/amp8/understanding-memory-problems
https://documentation.red-gate.com/amp8/strategies-for-memory-profiling
The you can check to see if it is fixed using this one:
https://documentation.red-gate.com/amp8/strategies-for-memory-profiling/checking-managed-memory-usage/checking-that-a-memory-leak-is-fixed
I hope this is helpful to you.
Redgate Software