New Relic APM JVM Heap Growth: Confirming a Leak Without Worsening Memory Pressure
0 reputation · 29 Sept 2023, 15:52 UTC
0 reputation · 29 Sept 2023, 15:52 UTC
New Relic APM's JVM overview surfaces heap used/committed, GC pause time, and GC count as the primary signals for a suspected memory leak. The Java agent samples these metrics on an interval and does not capture object-level detail, so heap trends alone cannot confirm whether growth originates from the application or from agent-side retention such as transaction trace and event sample limits.
Continuous Profiling can expose allocation hotspots that indicate leaks, but enabling it on a JVM already showing sustained heap growth introduces instrumentation overhead that may worsen latency or trigger OOM. The unresolved decision is whether to lower the profiler sampling interval to catch short-lived allocations or raise it to minimize overhead on a pressured process. Agent configuration keys, defaults, and feature names also vary by agent version, adding uncertainty to any tuning choice.
Given these constraints, what is the safest diagnostic sequence for confirming a leak using New Relic APM data before enabling continuous profiling in production? How should the profiler sampling interval be selected when the JVM is already under memory pressure? Which agent-side sample limits should be reviewed first to rule out agent-induced retention?
33775 reputation · 29 Sept 2023, 17:02 UTC
Before turning on Continuous Profiling on a JVM that is already showing sustained heap growth, follow a lightweight, data‑driven sequence that isolates application‑side leaks from agent‑side retention.
jcmd GC.run or jcmd GC.heap_dump) and compare the Heap Used before and after. A persistent increase post‑GC is a strong leak sign.transaction_traces.enabled and transaction_traces.max_sampleserror_events.enabled and error_events.max_samplescustom_events.enabled and custom_events.max_samplesnewrelic.yml or environment variables for the current agent version’s key names (they differ between 6.x, 7.x, and 8.x).max_samples to a low value) and observe if the heap trend stabilises. If the growth slows, the agent was a contributor.Live counts rising).When the JVM is already under pressure, the safest approach is to use a *higher* sampling interval (i.e., lower frequency). A 200 ms interval (5 samples per second) is a common compromise: it reduces CPU usage and the amount of metadata the agent keeps in memory, while still exposing long‑term allocation trends. If the heap grows noticeably during the profiling window, tighten the interval gradually—never below 100 ms unless you have verified that the JVM can tolerate the extra overhead.
transaction_traces.max_sampleserror_events.max_samplescustom_events.max_samplesspan_events.max_samplesLowering these limits shortens the retention window for agent‑generated objects, which often consumes a significant portion of the heap in high‑throughput applications.
Could you share the exact New Relic Java agent version you’re running? The naming of the configuration keys for sample limits varies between major releases, and knowing the version will let us point you to the precise settings.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.