There are 2 cases where we are reporting slightly wrong numbers for committed bytes in !eeheap. The main problem is that, in general, the number of committed bytes is not exactly heap_segment_committed - heap_segment_mem. We typically have some space before heap_segment_mem to store something.
Case 1: Normal (i.e. not frozen) segments
For regions, the code is doing the right thing using regions_committed_adjustment, which should be sizeof(aligned_plug_and_gap).
For segments, this is currently wrong. The adjustment should be segment_info_size as in make_heap_segment. Depending on whether or not background GC is enabled, you could have either OS_PAGE_SIZE (which is OS-dependent) or align(sizeof(heap_segment)).
Case 2: Frozen segments.
The difference should be pseginfo->ibFirstObject as in GCHeap::RegisterFrozenSegment. In the frozen object heap implementation, we specified that as sizeof(ObjHeader).
The inaccuracies are typically small, off by a few bytes up to a page per segment at most.
In https://github.com/dotnet/runtime/pull/72229 (and some earlier work), I introduced gc_heap::committed_by_oh and gc_heap::committed_by_oh_per_heap arrays. These arrays maintain the total number of bytes committed per heap and per object heap.
Whenever the inaccuracies are fixed, we should be able to compare the values stored in the array and the value reported by !eeheap and assert they are equal.
There are 2 cases where we are reporting slightly wrong numbers for committed bytes in
!eeheap
. The main problem is that, in general, the number of committed bytes is not exactlyheap_segment_committed - heap_segment_mem
. We typically have some space beforeheap_segment_mem
to store something.Case 1: Normal (i.e. not frozen) segments
regions_committed_adjustment
, which should besizeof(aligned_plug_and_gap)
.segment_info_size
as inmake_heap_segment
. Depending on whether or not background GC is enabled, you could have eitherOS_PAGE_SIZE
(which is OS-dependent) oralign(sizeof(heap_segment))
.Case 2: Frozen segments.
The difference should be
pseginfo->ibFirstObject
as inGCHeap::RegisterFrozenSegment
. In the frozen object heap implementation, we specified that assizeof(ObjHeader)
.The inaccuracies are typically small, off by a few bytes up to a page per segment at most.
In https://github.com/dotnet/runtime/pull/72229 (and some earlier work), I introduced
gc_heap::committed_by_oh
andgc_heap::committed_by_oh_per_heap
arrays. These arrays maintain the total number of bytes committed per heap and per object heap.Whenever the inaccuracies are fixed, we should be able to compare the values stored in the array and the value reported by
!eeheap
and assert they are equal.