summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alk@tut.by>2014-02-22 13:10:08 -0800
committerAliaksey Kandratsenka <alk@tut.by>2014-02-22 13:10:08 -0800
commiteb2d69014cb3e163f2ab3ed676fbedf5c3a97caa (patch)
tree7d2b9fed232c73b6a5cbee13c28f297595cb7339 /src
parenta92fc76f72318f7a46e91d9ef6dd24f2bcf44802 (diff)
downloadgperftools-eb2d69014cb3e163f2ab3ed676fbedf5c3a97caa.tar.gz
issue-489: made tests pass on enabled chromium-style decommitting
Diffstat (limited to 'src')
-rw-r--r--src/tests/tcmalloc_unittest.cc19
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);