(Memory Profiling) Comparing memory state

LloydLloyd Posts: 22
It would be cool to be able to compare 2 memory profile.
I wonder if it's possible?

The problem: I have a memory leak.
What I did: Start the application, take snapshot. Open a new form, close it, take an other snapshot.

Now I would like to compare these 2 snapshots to know what has not be freed when I closed my window.

Is there a simple way to achieve that?

Comments

  • Ho yeah, there is the comparison column....
    no worries!!
  • hu.... I do have problem....
    I have written a very simple test and ...
    deallocated object still shows up all object tab :cry:
    and there is no column which indicate they have been deallocated....
    nasty...

    is it a bug of am I missing something?

    my test:
    what I have is a form with a button. click the button it show a new form.

    no I start the application take a snapshot.
    click the button, close the new window, take an other snapshot.

    to my horror and dismay I have a new 'Form1' instance in the new objects...
  • Hi Lloyd,

    no this is not a bug. The Form object that you create when you click on the button will only disappear from memory when it has been 'completely' garbage collected. For a Form this is a 2 stage process as the Form class has a finalizer method. The first time the garbage collection runs the Form object will be move to the finalization queue to be finalized at some point. The next time the garbage collector runs the From object will have its finalizer method called and be removed from memory.

    Everytime you take a snapshot in ANTS Profiler, we force a garbage collection so that we can present useful data. You can see this 2 stage process by taking another snapshot - you will then see that the From has gone.

    There is an excellent article about the garbage collector at http://msdn.microsoft.com/msdnmag/issue ... fault.aspx

    Regards,

    Tom Harris

    Red Gate Software
  • OK, thanks for the explanation.
  • BTW, do you have, or do you plan to have a visual representation of the memory with links between object
    So that the referer graph could be quickly grasp and the root that need to be cut easily identified?
  • Hi,

    this is top of the list for version 3. We certainly need to show the shortest paths to root so that you can quickly see why an object is still being kept in memory. No concrete plans or timescales for v3 yet though.

    Keep posting with your thoughts.

    Thanks,

    Tom
Sign In or Register to comment.