Implement the DDMS heap walking (for native and managed heaps).
This gets you the DDMS histograms of what's on your heaps.
Change-Id: I7133d044030b10a787277faf3a77e20c565e69c5
diff --git a/src/heap.h b/src/heap.h
index 5b71d18..829bbb2 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -72,10 +72,13 @@
// Check sanity of all live references. Requires the heap lock.
static void VerifyHeap();
- // A weaker test than VerifyObject that doesn't require the heap lock,
+ // A weaker test than IsLiveObject or VerifyObject that doesn't require the heap lock,
// and doesn't abort on error, allowing the caller to report more
// meaningful diagnostics.
static bool IsHeapAddress(const Object* obj);
+ // Returns true if 'obj' is a live heap object, false otherwise (including for invalid addresses).
+ // Requires the heap lock to be held.
+ static bool IsLiveObjectLocked(const Object* obj);
// Initiates an explicit garbage collection.
static void CollectGarbage();
@@ -172,6 +175,9 @@
#endif
}
+ // dlmalloc_walk_heap-compatible heap walker.
+ static void WalkHeap(void(*callback)(const void*, size_t, const void*, size_t, void*), void* arg);
+
static void AddFinalizerReference(Object* object);
static size_t GetBytesAllocated() { return num_bytes_allocated_; }
@@ -258,6 +264,20 @@
DISALLOW_IMPLICIT_CONSTRUCTORS(Heap);
};
+class ScopedHeapLock {
+ public:
+ ScopedHeapLock() {
+ Heap::Lock();
+ }
+
+ ~ScopedHeapLock() {
+ Heap::Unlock();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedHeapLock);
+};
+
} // namespace art
#endif // ART_SRC_HEAP_H_