diff options
| -rw-r--r-- | src/dlmalloc.h | 12 | ||||
| -rw-r--r-- | src/native/dalvik_system_VMRuntime.cc | 4 | ||||
| -rw-r--r-- | src/space.cc | 14 | ||||
| -rw-r--r-- | src/space.h | 2 |
4 files changed, 17 insertions, 15 deletions
diff --git a/src/dlmalloc.h b/src/dlmalloc.h index cb09308aa1..e696f6e08c 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 8dbbc77cf6..33ece66e70 100644 --- a/src/native/dalvik_system_VMRuntime.cc +++ b/src/native/dalvik_system_VMRuntime.cc @@ -171,11 +171,7 @@ static void VMRuntime_trimHeap(JNIEnv*, jobject) { 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 f0f93231cd..324b495ddc 100644 --- a/src/space.cc +++ b/src/space.cc @@ -319,7 +319,11 @@ size_t AllocSpace::AllocationSize(const Object* obj) { 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, void* /*arg*/) { } } -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 bc1493d7d7..79d5ad44e3 100644 --- a/src/space.h +++ b/src/space.h @@ -320,8 +320,6 @@ class ImageSpace : public Space { // 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 |