Increase region space statistics about allocSize of Heap
ART currently uses a concurrent copying garbage collector, and the
corresponding allocation space uses a region space.
So when obtaining the heap state, we need to also fetch the statistics
of the region space.
Bug: 161244406
Test: Call VMDebug_getHeapSpaceStats interface
Signed-off-by: zhang chuang <zhangchuang3@xiaomi.com>
Change-Id: I07c00a23eeadde6cd1c3e3fb3388d43be74c99d4
diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc
index 7169a50..a090f35 100644
--- a/runtime/native/dalvik_system_VMDebug.cc
+++ b/runtime/native/dalvik_system_VMDebug.cc
@@ -415,6 +415,14 @@
gc::space::BumpPointerSpace* bump_pointer_space = space->AsBumpPointerSpace();
allocSize += bump_pointer_space->Size();
allocUsed += bump_pointer_space->GetBytesAllocated();
+ } else if (space->IsRegionSpace()) {
+ gc::space::RegionSpace* region_space = space->AsRegionSpace();
+ // When using the concurrent copying garbage collector, the corresponding allocation space
+ // uses a region space. The memory actually requested for the region space is to allow for
+ // a from-space and a to-space, and their sum is twice the actual available space. So here
+ // we need to divide by 2 to get the actual space size that can be used.
+ allocSize += region_space->Size() / 2;
+ allocUsed += region_space->GetBytesAllocated();
}
}
for (gc::space::DiscontinuousSpace* space : heap->GetDiscontinuousSpaces()) {