From 61c317b624e14eaefceca257473e9df97e1ced60 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Wed, 29 Mar 2017 13:56:24 -0700
Subject: [PATCH] Fix leak

---
 test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index b61b325dfa..8fbfd0fa13 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -147,9 +147,12 @@ template <int kLength>
 class SingleInternedBinaryElem {
  public:
   static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx *exec_ctx) {
-    return {grpc_mdelem_from_slices(
+    grpc_slice bytes = MakeBytes();
+    std::vector<grpc_mdelem> out = {grpc_mdelem_from_slices(
         exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
-        grpc_slice_intern(MakeBytes()))};
+        grpc_slice_intern(bytes))};
+    grpc_slice_unref(bytes);
+    return out;
   }
 
  private:
@@ -325,6 +328,8 @@ static void BM_HpackParserParseHeader(benchmark::State &state) {
     }
     grpc_exec_ctx_flush(&exec_ctx);
   }
+  for (auto slice : init_slices) grpc_slice_unref(slice);
+  for (auto slice : benchmark_slices) grpc_slice_unref(slice);
   grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
   grpc_exec_ctx_finish(&exec_ctx);
   track_counters.Finish(state);
-- 
GitLab