aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_arena.cc
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-03-14 07:50:56 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-03-14 07:50:56 -0700
commitff23f801c5fbb67d42b70c4ba0ba28ae2a7d31ae (patch)
tree659fed2e7046216b8a2edf304b8691b59272e6d8 /test/cpp/microbenchmarks/bm_arena.cc
parent09acb108b7620eff840fb0428f7eb159a4f27cf4 (diff)
Fix crash
Diffstat (limited to 'test/cpp/microbenchmarks/bm_arena.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_arena.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc
index 33e073f749..770c0b6d47 100644
--- a/test/cpp/microbenchmarks/bm_arena.cc
+++ b/test/cpp/microbenchmarks/bm_arena.cc
@@ -48,8 +48,15 @@ BENCHMARK(BM_Arena_NoOp)->Range(1, 1024 * 1024);
static void BM_Arena_ManyAlloc(benchmark::State& state) {
gpr_arena* a = gpr_arena_create(state.range(0));
+ const size_t realloc_after =
+ 1024 * 1024 * 1024 / ((state.range(1) + 15) & 0xffffff0u);
while (state.KeepRunning()) {
gpr_arena_alloc(a, state.range(1));
+ // periodically recreate arena to avoid OOM
+ if (state.iterations() % realloc_after == 0) {
+ gpr_arena_destroy(a);
+ a = gpr_arena_create(state.range(0));
+ }
}
gpr_arena_destroy(a);
}