From 4bf79d6d1b6e2cdcdab799c375b68b74f47aed56 Mon Sep 17 00:00:00 2001 From: Jack Berg <34418638+jack-berg@users.noreply.github.com> Date: Fri, 6 Mar 2026 08:44:38 -0600 Subject: [PATCH] Clear id cache before flushing output to resolve memory leak under load --- .../exporter/internal/marshal/ProtoSerializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java b/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java index 79bcd861ddd..8d815e19a6c 100644 --- a/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java +++ b/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java @@ -277,9 +277,9 @@ public void writeSerializedMessage(byte[] protoSerialized, String jsonSerialized @Override public void close() throws IOException { + idCache.clear(); try { output.flush(); - idCache.clear(); } catch (IOException e) { // If close is called automatically as part of try-with-resources, it's possible that // output.flush() will throw the same exception. Re-throwing the same exception in a finally