Page 1 of 1

Gaps in Generation #0

Posted: Thu Aug 14, 2014 2:12 pm
by acavender
Under Native Memory->Managed heaps->Normal heap->Generation #0, I am seeing the following numbers (see attached screenshot):

Code: Select all

Generation #0           41,282 KB
Reachable instances     13 KB
Gaps                    41,269 KB
This is the situation after running a snapshot. I am concerned about the 41MB gap in Gen #0 because this tells me that compaction is not going to be working. Gen #1 and Gen #2 look pretty normal to me (see screenshot). Does this imply there is memory being pinned in the Gen #0 heap that is preventing it from being fully compacted? I would expect if the 13 KB was toward the bottom part of the Generation #0 help, then the area above would be classified as Unused instead of a Gap.

Is this something I should be concerned about? If so, then what are some techniques to isolate that is causing the gap? I have looked at pinned memory instances, but nothing showed up as being in Gen #0.


Re: Gaps in Generation #0

Posted: Sun Aug 17, 2014 10:04 pm
by Andreas Suurkuusk
I have never seen a gap this big in the generation #0 heap, but I guess that it's possible that it could happen due to pinned instances. The runtime is able to perform allocations within gaps as well, but it does add some complexity to allocator and garbage collector, so it's desirable too avoid gaps like this.

You say that you don't have any pinned instances in gen#0. Do you have a lot of pinned instances in the other generations? How did you collect the heap snapshot (full snapshot or gen #0)?

We are looking into the native memory presentation to make sure that we are not accidentally presenting overhead as gaps.

Re: Gaps in Generation #0

Posted: Tue Aug 19, 2014 4:23 pm
by acavender

Thanks for the reply. I have been using full snapshots (and not just Gen #0). Your confirmation that this is likely an errant pinned piece of memory is pointing me back to doing a more thorough search of pinned instances. I could use a pointer to help, though. Is there a way in Memory Profiler to tell what generation a particular instance resides? I do not see anything obvious. If there was something like that, then I think this may not be too hard to track down.


Re: Gaps in Generation #0

Posted: Wed Aug 20, 2014 8:15 pm
by Andreas Suurkuusk
There are filters available for all generations, "Gen #0 instances", "Gen #1 instances", and "Gen #2 instances", but they are not added by default.To add a "Gen #0 instances" filter, use the command "Profiler->Manage filters", select "Gen #0 instances" in the list and click "Add filter".
Add Gen #0 filter
Hopefully this filter, together with "Pinned instances" analysis issue will help you locate the problem.