Switch art over to the new bionic dlmalloc 2.8.5 callback
Change-Id: I1314e87a51553fd358dbf9c44f804a7eb2de3a7d
diff --git a/src/dlmalloc.h b/src/dlmalloc.h
index cb09308..e696f6e 100644
--- a/src/dlmalloc.h
+++ b/src/dlmalloc.h
@@ -31,4 +31,16 @@
#include "dlmalloc/malloc.h"
#endif
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), void* arg);
+
+#ifdef __cplusplus
+}; /* end of extern "C" */
+#endif
+
#endif // ART_SRC_DLMALLOC_H_
diff --git a/src/native/dalvik_system_VMRuntime.cc b/src/native/dalvik_system_VMRuntime.cc
index 8dbbc77..33ece66 100644
--- a/src/native/dalvik_system_VMRuntime.cc
+++ b/src/native/dalvik_system_VMRuntime.cc
@@ -171,11 +171,7 @@
heap->Trim(alloc_space);
// Trim the native heap.
dlmalloc_trim(0);
-#if 0 // TODO: switch over to this when bionic has moved to dlmalloc 2.8.5
dlmalloc_inspect_all(MspaceMadviseCallback, NULL);
-#else
- dlmalloc_walk_free_pages(MspaceMadviseCallback, NULL);
-#endif
LOG(INFO) << "Parallel heap trimming took " << PrettyDuration(NanoTime() - start_ns)
<< " on a " << PrettySize(alloc_space_size)
<< " alloc space with " << static_cast<int>(100 * utilization) << "% utilization";
diff --git a/src/space.cc b/src/space.cc
index f0f9323..324b495 100644
--- a/src/space.cc
+++ b/src/space.cc
@@ -319,7 +319,11 @@
return mspace_usable_size(const_cast<void*>(reinterpret_cast<const void*>(obj))) + kChunkOverhead;
}
-void MspaceMadviseCallback(void* start, void* end, void* /*arg*/) {
+void MspaceMadviseCallback(void* start, void* end, size_t used_bytes, void* /* arg */) {
+ // Is this chunk in use?
+ if (used_bytes != 0) {
+ return;
+ }
// Do we have any whole pages to give back?
start = reinterpret_cast<void*>(RoundUp(reinterpret_cast<uintptr_t>(start), kPageSize));
end = reinterpret_cast<void*>(RoundDown(reinterpret_cast<uintptr_t>(end), kPageSize));
@@ -329,14 +333,6 @@
}
}
-void MspaceMadviseCallback(void* start, void* end, size_t used_bytes, void* arg) {
- // Is this chunk in use?
- if (used_bytes != 0) {
- return;
- }
- return MspaceMadviseCallback(start, end, arg);
-}
-
void AllocSpace::Trim() {
MutexLock mu(lock_);
// Trim to release memory at the end of the space.
diff --git a/src/space.h b/src/space.h
index bc1493d..79d5ad4 100644
--- a/src/space.h
+++ b/src/space.h
@@ -320,8 +320,6 @@
// Callback for dlmalloc_inspect_all or mspace_inspect_all that will madvise(2) unused
// pages back to the kernel.
void MspaceMadviseCallback(void* start, void* end, size_t used_bytes, void* /*arg*/);
-// Callback for the obsolete dlmalloc_walk_free_pages.
-void MspaceMadviseCallback(void* start, void* end, void* /*arg*/);
} // namespace art