Skip to content

G1 Old Memory leaking when using the javaagent with tracing and the grpc protocol under load #8143

@GerardoGR

Description

@GerardoGR

Describe the bug
G1 Old Memory leaking when using the javaagent with tracing and otel.exporter.otlp.protocol=grpc under load. I created this issue here because the ProtoSerializer is the leak suspect as also seen in #7083 #7083.

Edit 1: Updating the #7083 reference to point to the right opentelemetry-java GH issue.

Steps to reproduce

  1. Using a maven-version of the javaagent example
  2. Attaching the javaagent with the following parameters (leaky-1.0-SNAPSHOT.jar is the javaagent example jar):
SERVER_PORT=8080 java -Dfile.encoding=UTF-8 -Xms1024m -Xmx1024m -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heapdump.hprof -javaagent:opentelemetry-javaagent.jar -Dotel.service.name=leaky -Dotel.resource.attributes=service.instance.id=grpc -Dotel.instrumentation.common.default-enabled=true -Dotel.metric.export.interval=200 -Dotel.logs.exporter=none -Dotel.exporter.otlp.protocol=grpc -jar target/leaky-1.0-SNAPSHOT.jar
  1. Running simple load-test (k6) against the service:
import http from 'k6/http';

export const options = {
  scenarios: {
    hello: {
      executor: 'constant-vus',
      vus: 100,
      duration: '240m',
    },
  },
  noConnectionReuse: true,
};

export default function () {
  const response = http.get(`http://localhost:${__ENV.SERVER_PORT}/ping`);
}

What did you see?
When executing the k6 tests for ~3 hours, we see an ever-increasing heap G1 Old memory that leads eventually to java.lang.OutOfMemoryError:

Image Image

What did you expect to see?
Constant G1 Old heap memory.

What version and what artifacts are you using?
Artifacts: opentelemtry-javaagent=2.21.0, opentelemetry-sdk=1.55.0
How did you reference these artifacts? (excerpt from your build.gradle, pom.xml, etc)

# pom.xml
<dependency>
  <groupId>io.opentelemetry</groupId>
  <artifactId>opentelemetry-sdk</artifactId>
  <version>1.55.0</version>
  <scope>compile</scope>
</dependency>

Environment
Compiler: openjdk 17.0.2
OS: Apple M2 Pro
Note: The original memory leak was seen in our production systems, but I wanted to provide a "reproduction" case that can be run locally.

Additional context
Using otel.exporter.otlp.protocol=http/protobuf in the javaagent did not show signs of any memory leakage in the G1 Old heap memory.

Edit 2: Forgot to mention that I can provide the heapdump.hprof via email, I did not include it because there is a limit on the size of zip files in GH.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions