newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
202 stars 143 forks source link

R2dbc postgresql 0.9.2 memleak fix #1916

Closed obenkenobi closed 5 months ago

obenkenobi commented 5 months ago

Overview

Changes to the Postgres R2DBC 9.2+ instrumentation that improve memory usage. In particular, runs of this branch of the agent did not cause a growth in heap usage compared to the old agent over time.

Related Github Issue

https://github.com/newrelic/newrelic-java-agent/issues/1702

obenkenobi commented 5 months ago

While this memory leak requires running the app for a long time, one thing of note here is that even running a test app for almost 19 hours shown the JVM had to more and more increase the committed heap size while the agent with my fix did not (the only exception for the new agent was when my app ran for 3 hours).

image

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 70.65%. Comparing base (b582130) to head (fd42073). Report is 544 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1916 +/- ## ============================================ - Coverage 70.66% 70.65% -0.02% + Complexity 9876 9858 -18 ============================================ Files 828 826 -2 Lines 39848 39804 -44 Branches 6064 6062 -2 ============================================ - Hits 28160 28122 -38 + Misses 8960 8958 -2 + Partials 2728 2724 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

obenkenobi commented 5 months ago

At a higher load, the app with the old agent reached an out of memory condition and stopped reporting to New Relic.

The agent with my fix did not reach such condition.

image