Why trigger a SnapShot will still drop down the memory.

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.

Moderator: SciTech Software

Why trigger a SnapShot will still drop down the memory.

Postby Shawn » Thu Sep 22, 2016 2:54 am

Hi,
I have a
Code: Select all
GC.Collect()
at end of my testing program, I understand this is a blocking call and will free all un-reachable objects, if my program have no extra work any more, then the used memory should stayed in a fixed value, and this has been proved via the Graph and statistics.
But at this point, once I performed a SnapShot, I still can see a extra memory(Live managed bytes) drop down , what did the snap shot do here? not just trigger a Full GC?
Shawn
 
Posts: 5
Joined: Thu Nov 14, 2013 7:38 am

Re: Why trigger a SnapShot will still drop down the memory.

Postby Andreas Suurkuusk » Thu Sep 22, 2016 8:52 pm

When you collect a snapshot in the profiler, the profiler performs a sequence similar to:

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

It may even repeat this if it believes that there are still more instances to finalize.

So in your case, there's a possibility that there are instances with pending finalizers after your call to GC.Collect() and that would explain why the live bytes value decreases when you collect the snapshot.
Best regards,

Andreas Suurkuusk
SciTech Software AB
Andreas Suurkuusk
 
Posts: 976
Joined: Wed Mar 02, 2005 7:53 pm
Location: Sweden


Return to Using .NET Memory Profiler

Who is online

Users browsing this forum: Bing [Bot] and 12 guests

SciTech Software logo

© Copyright 2001-2016. SciTech Software AB
All rights reserved.


SciTech Software AB
Kartvägen 21
SE-175 46 Järfälla
Sweden


E-mail: mail@scitech.se

Telephone: +46-706868081