diff options
Diffstat (limited to 'src/tests/tcmalloc_unittest.cc')
-rw-r--r-- | src/tests/tcmalloc_unittest.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tests/tcmalloc_unittest.cc b/src/tests/tcmalloc_unittest.cc index 5f5cdb0..6a90e3b 100644 --- a/src/tests/tcmalloc_unittest.cc +++ b/src/tests/tcmalloc_unittest.cc @@ -869,6 +869,23 @@ static size_t GetUnmappedBytes() { } #endif +class AggressiveDecommitDisabler { + size_t old_value_; +public: + AggressiveDecommitDisabler() { + MallocExtension *inst = MallocExtension::instance(); + bool rv = inst->GetNumericProperty("tcmalloc.aggressive_memory_decommit", &old_value_); + CHECK_CONDITION(rv); + rv = inst->SetNumericProperty("tcmalloc.aggressive_memory_decommit", 0); + CHECK_CONDITION(rv); + } + ~AggressiveDecommitDisabler() { + MallocExtension *inst = MallocExtension::instance(); + bool rv = inst->SetNumericProperty("tcmalloc.aggressive_memory_decommit", old_value_); + CHECK_CONDITION(rv); + } +}; + static void TestReleaseToSystem() { // Debug allocation mode adds overhead to each allocation which // messes up all the equality tests here. I just disable the @@ -880,6 +897,8 @@ static void TestReleaseToSystem() { const double old_tcmalloc_release_rate = FLAGS_tcmalloc_release_rate; FLAGS_tcmalloc_release_rate = 0; + AggressiveDecommitDisabler disabler; + static const int MB = 1048576; void* a = malloc(MB); void* b = malloc(MB); |