A starter question on analyze memory profile, thanks

I am trying ANTS profiler. But haven't got the idea how to use it. After take snapshot, I see many objects, but I am not sure if they are all objects that are created so far, if they are all objects that were created, how can I tell from them which ones are the ones that causes problem?

For example, I have a gridview, it has 100 rows, on each rows, several usercontrols will be shown in several columns. After I call the page, should I see objects of all those usercontrols? how do I tell they will be collected by GC or they will not be since they have reference on them? I tried to click "Force GC", I thought after this, and then I take another snapshot, which remain in the all objects should be only those objects that can not be collected by GC, if they are not designed to be reminded in memory, they should be the problematic ones? but I did find much change after I click "Force GC".

Can anyone give me some idea here?



  • Brian DonahueBrian Donahue Posts: 6,590 New member

    ANTS Profiler does force a garbage collection every time a snapshot is taken, so it's really not necessary to use the force GC button. The only exception to this is objects that are pending finalization, which can take at least two GC collections to be disposed of.

    Obviously, memory profiling is a HUGE topic and I don't think I could cover it all in one reply. The essence of it is that you are looking for, first, classes with the most live instances and secon, the largest live objects. Classes with many live instances can be live for many reasons, the previously mentioned waiting for finalization, or because they are attached to a live root object.

    You may want to have a look at the ANTS Profiler technical papers section; there is some information that may help.
  • Thanks for you quickly reply.
    I have read some article about ANTS profiler.

    So if the same webpage, in normal case, when I refresh a web page, I should not see any new object in my namespace, right? unless I have static class in it. Those objects were created to create output for the web page should be collected by GC before taking snapshot. Otherwise it means something is not right and memory will build up and never release, right?
  • For every web page, I will create a object from class LinkPage, in it, I will create othre objects include GridView etc. I found after the page load, I took snapshot, then force GC, then another snapshot. The LinkPage object is still there, and it references by 2412 objects - most are its children I think, and it refer to 52 objects. Object like this how do I find out what is the problem, I think it is not a problem its children reference it. But which is the one that keep it from release? if the linkpage can not be released, its children will not, right?
Sign In or Register to comment.