summaryrefslogtreecommitdiff
path: root/src/tests/tcmalloc_unittest.cc
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alkondratenko@gmail.com>2021-02-28 17:47:56 -0800
committerAliaksey Kandratsenka <alkondratenko@gmail.com>2021-02-28 17:47:56 -0800
commita015377a54eb09fca4b893ae530187a705164df5 (patch)
tree448d98fad98cac49536efea9587c86040e537458 /src/tests/tcmalloc_unittest.cc
parentc939dd5531fd95e8af2181ac60e0b6e6230226c8 (diff)
downloadgperftools-a015377a54eb09fca4b893ae530187a705164df5.tar.gz
Set tcmalloc heap limit prior to testing oom
Otherwise it can take long time to OOM on osex.
Diffstat (limited to 'src/tests/tcmalloc_unittest.cc')
-rw-r--r--src/tests/tcmalloc_unittest.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tests/tcmalloc_unittest.cc b/src/tests/tcmalloc_unittest.cc
index f1bc078..658772f 100644
--- a/src/tests/tcmalloc_unittest.cc
+++ b/src/tests/tcmalloc_unittest.cc
@@ -1615,11 +1615,16 @@ static int RunAllTests(int argc, char** argv) {
// Check that large allocations fail with NULL instead of crashing
#ifndef DEBUGALLOCATION // debug allocation takes forever for huge allocs
fprintf(LOGSTREAM, "Testing out of memory\n");
+ size_t old_limit;
+ CHECK(MallocExtension::instance()->GetNumericProperty("tcmalloc.heap_limit_mb", &old_limit));
+ // Don't exercise more than 1 gig, no need to.
+ CHECK(MallocExtension::instance()->SetNumericProperty("tcmalloc.heap_limit_mb", 1 << 10));
for (int s = 0; ; s += (10<<20)) {
void* large_object = rnd.alloc(s);
if (large_object == NULL) break;
free(large_object);
}
+ CHECK(MallocExtension::instance()->SetNumericProperty("tcmalloc.heap_limit_mb", old_limit));
#endif
TestHugeThreadCache();