2 snapshots required

Use this forum to discuss subjects that don't belong in the other forums.
Post Reply
Dave
Posts: 6
Joined: Fri Jan 27, 2006 3:29 pm

2 snapshots required

Post by Dave » Thu Aug 15, 2013 12:42 am

Attached is a real-time plot of total bytes. In it, I performed the same action 3 times. After each action, I collected 2 heap snapshots. As you can see, I got part of the memory back after the first snapshot and the rest back after the second snapshot.

Why do I need two heap snapshots to get the memory back? Assuming its something in my code, do you have any tips on how to identify what is keeping the memory from being collected after the first heap snapshot?

Thanks in advance!
Attachments
Realtime - 2Snapshots.png

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

Re: 2 snapshots required

Post by Andreas Suurkuusk » Thu Aug 15, 2013 3:37 pm

I believe that you have references that are not released immediately after you perform the action. Maybe you have instances that are stored in a cache that gets cleared after a while, or in a session that expires.

If you compare the two snapshots you should be able to find types with a negative delta value for live instances and live bytes. After you have identified types with a negative delta, you can select the first snapshot and hopefully you will be able to identify the instances that exists in the first snapshot but not the second. Unfortunately it is not possible to retrieve information about specific removed instances, since the profiler only presents a count of removed instances. This is something we might improve in a future version.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Dave
Posts: 6
Joined: Fri Jan 27, 2006 3:29 pm

Re: 2 snapshots required

Post by Dave » Thu Aug 15, 2013 8:34 pm

I found part of my problem. Apparently when you add an array of objects to a ListBox, it caches the objects in an 'entries' member even after you call Clear(). Calling Clear() will set the number of items to 0, but the cached objects will remain. However, if you call <ListBox>.Items.RemoveAt(index) it will remove the objects from the entries.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests