summaryrefslogtreecommitdiff
path: root/runtime/gc/allocator/rosalloc.cc
diff options
context:
space:
mode:
author Hiroshi Yamauchi <yamauchi@google.com> 2016-02-19 01:52:38 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-02-19 01:52:38 +0000
commitad736f19b4ab0b1767fba9ed124f12e74313fcbb (patch)
tree93b0c7a96db06d2b9bfdcf0cbf3538fc15f5ad93 /runtime/gc/allocator/rosalloc.cc
parent5532365a289c8c2e8cb827c07058d72eb38f2e1c (diff)
parentb5e31f3dd5f792ff60225a4daa048a57d261cdd0 (diff)
Merge "Fix rosalloc issues with valgrind."
Diffstat (limited to 'runtime/gc/allocator/rosalloc.cc')
-rw-r--r--runtime/gc/allocator/rosalloc.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index 8b125dd167..2c487fe8df 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -58,10 +58,16 @@ RosAlloc::RosAlloc(void* base, size_t capacity, size_t max_capacity,
page_release_mode_(page_release_mode),
page_release_size_threshold_(page_release_size_threshold),
is_running_on_memory_tool_(running_on_memory_tool) {
+ DCHECK_ALIGNED(base, kPageSize);
DCHECK_EQ(RoundUp(capacity, kPageSize), capacity);
DCHECK_EQ(RoundUp(max_capacity, kPageSize), max_capacity);
CHECK_LE(capacity, max_capacity);
CHECK_ALIGNED(page_release_size_threshold_, kPageSize);
+ // Zero the memory explicitly (don't rely on that the mem map is zero-initialized).
+ if (!kMadviseZeroes) {
+ memset(base_, 0, max_capacity);
+ }
+ CHECK_EQ(madvise(base_, max_capacity, MADV_DONTNEED), 0);
if (!initialized_) {
Initialize();
}