Dynatrace + OkHttp3 memory leak

Hi,

We believe we’ve stumbled on a memory leak caused by the Dynatrace default interceptor.

We observed applications mysteriously restarting due to OOMs. Upon further investigation (jemalloc tuning), it was revealed that the native memory allocator from the Dynatrace native lib was hoarding twice our heap in memory.

Here’s a picture of the relevant allocation stack showing this.

And because I’m sure it’s useful, here’s the one agent version information in a copy/pasteable form

/opt/dynatrace/oneagent-paas/agent/bin/1.315.68.20250627-182234/linux-x86-64/liboneagentjava.so

We’ve observed that switching to a non-OkHttpClient client fixes this problem.

Here’s another shot of one of the paths taken

It appears that memory allocated by `CorrelationNative` isn’t being properly (or timely) released for the OkHttp integration.

4 Likes

@tmay Thank you very much for providing the feedback and solution!