Options

Memory leaks

Hi,

I am using ANTS Memory profile, i am unable to identify memory leaks from the snap shot. Kindly guide me, how to identify memory leaks from snap shot result report.

Thanks in advance,
Ram.

Comments

  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi,

    That's a bit of a hard question, but the idea is to use the memory profiling summary to find the biggest objects and the 10 classes with the most live instances and focus on them. To try to figure out why there are so many live objects, you can use the 'all objects' tabbed page and use the filters to show all instances of the particular class that you have a lot of.

    Next, you can use the hierarchy tab to trace back where these objects are being allocated and the source code tab to find the place in code.

    ANTS Profiler is not going to tell you why an object is still in memory or even the best way to correct the problem. Usually you want to dispose all of your objects that implement IDisposable.

    Any other modifications that you can make to your code to free up unnecessary memory is a bit of an art form, I'm afraid!
  • Options
    Hi there,

    as Brian points out there is no really easy way to get a list of objects that are 'memory leaks'. However, I do find the following technique useful -
    Profile the memory of your application and then take a snapshot before you think that your leak happens (e.g before you create a new form etc.). Then take another snapshot after you think the leak has happened. In the 'All objects' tab you can filter on state so that you only see any new objects that have been created since the last snapshot. This should give you a much smaller set of objects to focus attention on. If there are any obvious objects in this set that you would have expected to have been cleaned up then investigate the hierarchy to see why they are still alive.

    More details at
    http://www.red-gate.com/products/ANTS_P ... bjects.htm

    Good luck!,

    Tom Harris
Sign In or Register to comment.