From ff23f801c5fbb67d42b70c4ba0ba28ae2a7d31ae Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 14 Mar 2017 07:50:56 -0700 Subject: [PATCH] Fix crash --- test/cpp/microbenchmarks/bm_arena.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc index 33e073f7495..770c0b6d474 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); }