More of the concurrent copying collector.
Bug: 12687968
Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index 0b04276..d2e93bc 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -507,7 +507,7 @@
Env env = { this, output };
runtime->VisitRoots(RootVisitor, &env);
- runtime->GetHeap()->VisitObjects(VisitObjectCallback, &env);
+ runtime->GetHeap()->VisitObjectsPaused(VisitObjectCallback, &env);
output->StartNewRecord(HPROF_TAG_HEAP_DUMP_END, kHprofTime);
output->EndRecord();
@@ -1151,10 +1151,20 @@
void DumpHeap(const char* filename, int fd, bool direct_to_ddms) {
CHECK(filename != nullptr);
+ Thread* self = Thread::Current();
+ gc::Heap* heap = Runtime::Current()->GetHeap();
+ if (heap->IsGcConcurrentAndMoving()) {
+ // Need to take a heap dump while GC isn't running. See the
+ // comment in Heap::VisitObjects().
+ heap->IncrementDisableMovingGC(self);
+ }
Runtime::Current()->GetThreadList()->SuspendAll();
Hprof hprof(filename, fd, direct_to_ddms);
hprof.Dump();
Runtime::Current()->GetThreadList()->ResumeAll();
+ if (heap->IsGcConcurrentAndMoving()) {
+ heap->DecrementDisableMovingGC(self);
+ }
}
} // namespace hprof