Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Release backlog memory when features are blocked by RUM #1102

Merged
merged 8 commits into from
Jul 9, 2024

Conversation

cwli24
Copy link
Contributor

@cwli24 cwli24 commented Jul 3, 2024

Plug a memory leak in Session Trace and other features. When entitlement or enable flag from RUM request returns a 0 for a feature, the agent will now release the reference to the events buffer under that feature so it can be garbage collected.

Overview

The pre-load cycle of the agent sets up listeners and buffers events in a backlog and an internal handlers object to be flushed and processed after the page loads. It was discovered that if the RUM call getting made post-load returns a 0 for an applicable feature, those things are never cleared for such feature. This caused the backlog for instance to indefinitely hold onto events awaiting processing, consuming memory. This fix will flush those events in such cases when the features are not activated via the deregisterDrain call made by each.

Related Issue(s)

https://new-relic.atlassian.net/browse/NR-284960
This issue was also seen in other features and have been addressed together.

Testing

New e2e on -b *:
image

Copy link

github-actions bot commented Jul 3, 2024

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 34.16 kB / 11.9 kB (gzip) 34.25 kB / 11.92 kB (gzip) 0.26% / 0.16% (gzip)
lite async-chunk 50.09 kB / 16.18 kB (gzip) 50.09 kB / 16.18 kB (gzip) 0% / 0% (gzip)
pro loader 54.83 kB / 18.55 kB (gzip) 54.92 kB / 18.57 kB (gzip) 0.16% / 0.11% (gzip)
pro async-chunk 96.73 kB / 28.99 kB (gzip) 96.73 kB / 28.99 kB (gzip) 0% / 0% (gzip)
spa loader 62.77 kB / 20.97 kB (gzip) 62.86 kB / 21 kB (gzip) 0.14% / 0.14% (gzip)
spa async-chunk 111.84 kB / 33.37 kB (gzip) 111.84 kB / 33.37 kB (gzip) 0% / 0% (gzip)
lite-polyfills loader 127.79 kB / 41.22 kB (gzip) 127.83 kB / 41.24 kB (gzip) 0.03% / 0.04% (gzip)
lite-polyfills async-chunk 63.99 kB / 18.45 kB (gzip) 63.99 kB / 18.45 kB (gzip) 0% / 0% (gzip)
pro-polyfills loader 150.17 kB / 47.51 kB (gzip) 150.21 kB / 47.54 kB (gzip) 0.03% / 0.05% (gzip)
pro-polyfills async-chunk 116.73 kB / 31.22 kB (gzip) 116.73 kB / 31.22 kB (gzip) 0% / 0% (gzip)
spa-polyfills loader 158.37 kB / 49.67 kB (gzip) 158.41 kB / 49.69 kB (gzip) 0.03% / 0.04% (gzip)
spa-polyfills async-chunk 133.71 kB / 35.92 kB (gzip) 133.71 kB / 35.92 kB (gzip) 0% / 0% (gzip)

Copy link

github-actions bot commented Jul 3, 2024

Static Badge

Last ran on July 09, 2024 11:59:53 CDT
Checking merge of (d6f1e8d) into main (3d815a3)

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.63%. Comparing base (3d815a3) to head (c4d8ba5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1102   +/-   ##
=======================================
  Coverage   87.62%   87.63%           
=======================================
  Files         162      162           
  Lines        7259     7263    +4     
  Branches     1423     1426    +3     
=======================================
+ Hits         6361     6365    +4     
  Misses        782      782           
  Partials      116      116           
Flag Coverage Δ
unit-tests 76.44% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@patrickhousley
Copy link
Contributor

I did some manual testing locally. Here are my findings.

Looks like the backlog is getting cleared correctly when SR and ST are enabled in the agent config but RUM responds with a 0.
image

Co-authored-by: Patrick Housley <patrickhousley@users.noreply.github.com>
@cwli24 cwli24 merged commit 5eb9164 into main Jul 9, 2024
18 checks passed
@cwli24 cwli24 deleted the clear-mem-blocked branch July 9, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants