diff options
| author | 2020-07-15 11:06:42 +0800 | |
|---|---|---|
| committer | 2020-08-05 10:46:29 +0000 | |
| commit | 8a8e1c5b4ccda0619c7bc946bc4790ea44ff8286 (patch) | |
| tree | 363145d76a2d31aa2424c4bddab8016951945ca0 /runtime/native/dalvik_system_VMDebug.cc | |
| parent | 39e99da15c2410646686465945881e404c84f7c3 (diff) | |
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
Diffstat (limited to 'runtime/native/dalvik_system_VMDebug.cc')
| -rw-r--r-- | runtime/native/dalvik_system_VMDebug.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc index 7169a5078e..a090f356ac 100644 --- a/runtime/native/dalvik_system_VMDebug.cc +++ b/runtime/native/dalvik_system_VMDebug.cc @@ -415,6 +415,14 @@ static void VMDebug_getHeapSpaceStats(JNIEnv* env, jclass, jlongArray data) { 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()) { |