diff options
author | Aliaksey Kandratsenka <alk@tut.by> | 2014-02-22 13:10:08 -0800 |
---|---|---|
committer | Aliaksey Kandratsenka <alk@tut.by> | 2014-02-22 13:10:08 -0800 |
commit | eb2d69014cb3e163f2ab3ed676fbedf5c3a97caa (patch) | |
tree | 7d2b9fed232c73b6a5cbee13c28f297595cb7339 /src | |
parent | a92fc76f72318f7a46e91d9ef6dd24f2bcf44802 (diff) | |
download | gperftools-eb2d69014cb3e163f2ab3ed676fbedf5c3a97caa.tar.gz |
issue-489: made tests pass on enabled chromium-style decommitting
Diffstat (limited to 'src')
-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); |