Page 1 of 1

Gen #2 instances question

PostPosted: Mon Aug 14, 2017 1:07 pm
by DanS
I looked over the documentation, but could not find an answer to my question. Does the number of Gen #2 instances reflect the number of objects ready for GC which survived Gen #0 and Gen #1? The reason I ask is that I’m seeing a lot of memory listed as Gen #2, and our application is having OOM issues. I’m wondering if there is a blocked finalizer not allowing for the Gen #2 memory to be cleaned up. Here is a screen shot of the profiler.

Screen Shot

Re: Gen #2 instances question

PostPosted: Tue Aug 15, 2017 11:48 am
by Andreas Suurkuusk
The number of gen #2 instances reflects the number of instances that have survived a gen #0 and gen #1 collection, but are still reachable from a root. So they are not eligible for garbage collection. Note that when you collect a full snapshot in the profiler, the profiler performs several full GCs in order to only present actual live instances. If you want to get information about unreachable instances, you can use the "Collect gen#0 snapshot" command instead (or attach to the process using "Inspection only attach"). This will prevent a full garbage collection from being performed and there will still exist unreachable instances in the heap (see screenshot).


Whether there are instances that are waiting to be finalized, or if there is a blocked finalizer, is not possible to determine from the screenshot. You can get more information about how the instances are kept alive by investigating the root paths of the instances (e.g. by investigating the Type details). If possible, I recommend that you run the profiled process under the profiler (e.g. by using "Profile application"). This way you will get much more detailed information, for instance information about potentially blocked finalizers.

Re: Gen #2 instances question

PostPosted: Tue Aug 15, 2017 1:26 pm
by DanS
Thank you. I'm still learning about Garbage Collection and your tool.