diff options
author | Yang Gao <yangg@google.com> | 2018-12-18 21:36:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 21:36:50 -0800 |
commit | 5763add7c9ede9664946212bf2980723376d7b5f (patch) | |
tree | 582e529d30b433dce62448f136332e275d8445be | |
parent | 916aeffa66c4f4cbdd6444ab03f34803bc0f0ca1 (diff) | |
parent | 82797771679c93045876f48707c5cb46bfae4f53 (diff) |
Merge pull request #17554 from g-easy/oc
Destruct CensusContext to avoid leaking memory.
-rw-r--r-- | src/cpp/ext/filters/census/context.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cpp/ext/filters/census/context.cc b/src/cpp/ext/filters/census/context.cc index 78fc69a805..160590353a 100644 --- a/src/cpp/ext/filters/census/context.cc +++ b/src/cpp/ext/filters/census/context.cc @@ -28,6 +28,9 @@ using ::opencensus::trace::SpanContext; void GenerateServerContext(absl::string_view tracing, absl::string_view stats, absl::string_view primary_role, absl::string_view method, CensusContext* context) { + // Destruct the current CensusContext to free the Span memory before + // overwriting it below. + context->~CensusContext(); GrpcTraceContext trace_ctxt; if (TraceContextEncoding::Decode(tracing, &trace_ctxt) != TraceContextEncoding::kEncodeDecodeFailure) { @@ -42,6 +45,9 @@ void GenerateServerContext(absl::string_view tracing, absl::string_view stats, void GenerateClientContext(absl::string_view method, CensusContext* ctxt, CensusContext* parent_ctxt) { + // Destruct the current CensusContext to free the Span memory before + // overwriting it below. + ctxt->~CensusContext(); if (parent_ctxt != nullptr) { SpanContext span_ctxt = parent_ctxt->Context(); Span span = parent_ctxt->Span(); |