summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/debugger.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index a9b70cbaa1..c726c8299c 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -4316,6 +4316,12 @@ class HeapChunkContext {
size_t needed = (((length/ALLOCATION_UNIT_SIZE + 255) / 256) * 2) + 17;
size_t bytesLeft = buf_.size() - (size_t)(p_ - &buf_[0]);
if (bytesLeft < needed) {
+#if defined(HAVE_ANDROID_OS) && defined(USE_DLMALLOC)
+ // Cannot trigger memory allocation while walking native heap.
+ if (type_ == CHUNK_TYPE("NHSG")) {
+ return;
+ }
+#endif
Flush();
}
@@ -4435,7 +4441,9 @@ void Dbg::DdmSendHeapSegments(bool native) {
HeapChunkContext context((what == HPSG_WHAT_MERGED_OBJECTS), native);
if (native) {
#if defined(HAVE_ANDROID_OS) && defined(USE_DLMALLOC)
+ ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_);
dlmalloc_inspect_all(HeapChunkContext::HeapChunkCallback, &context);
+ HeapChunkContext::HeapChunkCallback(NULL, NULL, 0, &context); // Indicate end of a space.
#else
UNIMPLEMENTED(WARNING) << "Native heap inspection is only supported with dlmalloc";
#endif