Memory profiling: Comparing different results?

mihiesmihies Posts: 71 Bronze 4
I assume the Compare column means the difference within two sequential results, right?
So, how would I compare two non-sequential results?
The problem I am facing is this:
1. take snapshot
2. show some form
3. take snapshot (memory increase is relatively huge)
4. take snapshot (memory increase to initial state is small)

OK, tha anomaly I am seeing is probably due to garbage collection. But I like to see what objects, or better, what classes survived after first snapshot. Am I supposed to search objects (I can't look at classes i guess) with Age = 2.

Thanks[/list]
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
Blog:http://blog.rthand.com
Righthand .net consulting and software development
http://www.rthand.com

Comments

  • I assume the Compare column means the difference within two sequential results, right?

    Yes, that's correct.

    So, how would I compare two non-sequential results?

    The anomaly you are seeing is possibly due to finalization. The first time you do a snapshot, the garbage collector is called, which sets about finalizing the objects. On the second snapshot, the garbage collector actually collects them.

    ANTS Profiler does not have a direct method of comparing non-sequential snapshots. Would you like to compare your first and your third snapshot, to see which objects have survived? This is probably best down by looking at the age column.

    You can easily filter by age. In the All Objects View, hover the mouse over the word 'Age' heading the age column. A small grey icon will appear just above and to the right of the word 'Age'. Click on it. Then use the drop-down list to filter by Age.
    Jason Crease
    Red Gate Software
  • mihiesmihies Posts: 71 Bronze 4
    I think I know how to filter this grid :-)

    Does Age value count "normal" garbage collection, too? Or it counts only Profiler explicit GCs when doing snapshot?
    Miha Markic [MVP C#, INETA Country Leader for Slovenia]
    Blog:http://blog.rthand.com
    Righthand .net consulting and software development
    http://www.rthand.com
  • 'Age' only counts "natural" garbage collections. It does not count explicit GCs caused by snapshots.

    Although both are standard garbage collections, we felt that counting explicit ones caused by snapshots as well as "natural" ones would obscure the results.
    Jason Crease
    Red Gate Software
  • mihiesmihies Posts: 71 Bronze 4
    So, regarding to suggestion above (that I should filter by age to find out new objects), how can I know what age to filter for?
    Miha Markic [MVP C#, INETA Country Leader for Slovenia]
    Blog:http://blog.rthand.com
    Righthand .net consulting and software development
    http://www.rthand.com
  • I'm not quite sure I understand your question. As I understand it:

    1. Start program
    2. Show form

    And no "natural" GCs occur at any point. You would like to know which objects are created by the form, and which were created at the beginning of the program. Is this correct?
    Jason Crease
    Red Gate Software
  • mihiesmihies Posts: 71 Bronze 4
    Hi Jason,
    JasonC wrote:
    I'm not quite sure I understand your question. As I understand it:

    1. Start program
    2. Show form

    And no "natural" GCs occur at any point.

    Ehm, why not? I mean one can't be sure. Isn't GC supposed to run at any time it deems necessary?
    JasonC wrote:
    You would like to know which objects are created by the form, and which were created at the beginning of the program. Is this correct?

    Yes, I would like to know, which objects are not removed after:
    3. Close form

    Thus I need to know which ones were created by the form. I would compare two results but I can't due to 2-step garbage collection which yields usable results only on second snapshot and thus I can't compare them.
    I guess here is a suggestion: Add a button to do GC manually, not just within snapshot so one can do a manual GC before taking the snapshot and the two results can be compared.
    Miha Markic [MVP C#, INETA Country Leader for Slovenia]
    Blog:http://blog.rthand.com
    Righthand .net consulting and software development
    http://www.rthand.com
  • Indeed, but a fairly ugly solution. We will be looking to add much better comparison of all snapshots in ANTS Profiler 3. For now a forced gc is going to be the best option :oops:

    Regards,

    Tom Harris

    Red Gate Software
  • I’m trying to profile my application using almost the same scenario:
    1) Start application
    2) Take snapshot
    3) Open some UI and close it
    4) Take snapshot (some UI controls still in memory)
    5) Take snapshot (part of UI controls from 4) released).

    I have some confusion with result from 4) and 5). It doesn’t matter if I wait few minutes after I closing UI in section 3 till I taking snapshot from section 4) there are always few ui controls stays in memory (as I understand from it that they not garbage collected – because I waited long enough). But when take immediately snapshot from 5) they are gone. I made various verifications for that scenario with various snapshot times – there is always the same result. I’m not understand why controls stay in snapshot 4) and gone in 5).
    Any suggestions?

    Thanks in advance

    Yevgeny.
  • Hi Yevgeny,

    The chances are, that if the UI controls require Finalization (quite common), then on the first garbage collect (triggered by 4), they will be marked as needing finalization, and moved to the finalize queue.

    Only when you take the second snapshot, at 5, do they actually get garbage collected.

    If, between stages 4 and 5, your application is not actively allocating new objects, then it's entirely possible that no other garabage collections will be triggered, which is why you don't see the UI controls getting released until you take the snapshot (which forces a GC).

    Hope that helps,
    Robert
    Robert Chipperfield
    Red Gate
Sign In or Register to comment.