How to use API for Debug Tracing of potential leaks?

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
AaronL
Posts: 1
Joined: Thu Jun 05, 2008 12:19 am

How to use API for Debug Tracing of potential leaks?

Post by AaronL » Thu Jun 05, 2008 12:37 am

I'm working with a large modular application. Where there is a parent child relationship between most objects like that of Forms to User Controls. Using the .Net Memory Profiler we can see references are still holding on to forms in many cases. Or an event subscription is causing a controller class to remain in memory etc.

In these situations of parent to child relationships, the child object commonly has a Close method. This Close method should clean up all allocation paths to the object except that of the parent. During development testing I'd like to have enabled some tracing function called by each Close method that would trace a warning if it detected any root paths that did not go through the parent.

Is it feasible to write such a function using the MemProfiler API? And do you have any guidance or samples for where I could start?

I'd expect there to be a performance cost when the tracing is enabled and a small percentage of false positives would be acceptable.

Any help is appreciated.

Aaron

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Post by Andreas Suurkuusk » Thu Jun 05, 2008 3:21 pm

I'm afraid that this is not possible to do in the current version of the profiler. In the next version we will provide full API access to the snapshot data, so then you would be able to collect a snapshot in the Close method and analyse the root paths using the new API. However, this would require a full snapshot to be collected in the Close method, which will slow things down considerably and create large session files.

We are also working on improving the memory assertions for the next version and I believe that the new assertions functionality might be useful in your case.

In the meantime I think that you will have to analyse the snapshot manually, but you can of course trigger the snapshot collection from the Close method.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 22 guests