Add a way to determine if a large object is a zygote object
Also fix a slight memory leak in LargeObjectMapSpace.
Bug: 20674158
(cherry picked from commit 8f23620d45399286564986d2541cda761b3fe0ac)
Change-Id: I2416df484e5b84a8c5cc0b5664c8cb102dc235f6
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 922fc5f..6e0e56e 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -891,8 +891,8 @@
return;
}
- gc::space::ContinuousSpace* space =
- Runtime::Current()->GetHeap()->FindContinuousSpaceFromObject(obj, true);
+ gc::Heap* const heap = Runtime::Current()->GetHeap();
+ const gc::space::ContinuousSpace* const space = heap->FindContinuousSpaceFromObject(obj, true);
HprofHeapId heap_type = HPROF_HEAP_APP;
if (space != nullptr) {
if (space->IsZygoteSpace()) {
@@ -900,6 +900,11 @@
} else if (space->IsImageSpace()) {
heap_type = HPROF_HEAP_IMAGE;
}
+ } else {
+ const auto* los = heap->GetLargeObjectsSpace();
+ if (los->Contains(obj) && los->IsZygoteLargeObject(Thread::Current(), obj)) {
+ heap_type = HPROF_HEAP_ZYGOTE;
+ }
}
CheckHeapSegmentConstraints();