bugsnag / bugsnag-unity-performance

Monitor the start-up, scene loading and network requests of your Unity game and see the results in your BugSnag dashboard.
https://docs.bugsnag.com/performance/integration-guides/unity
MIT License
1 stars 2 forks source link

PLAT-10952 convert span refs to weak refs to avoid memory leaks #127

Closed richardelms closed 2 months ago

richardelms commented 2 months ago

Goal

Convert span refs to weak refs to avoid memory leaks

Changeset

Changes to Span.Discard(), Span.End() and cleaning span collections in BugsnagPerformance.

Now that the collection BugsnagPerformance._potentiallyOpenSpans is a weak reference collection, it's no longer important to remove spans from it when they are ended. Because of this it is also no longer necessary to call the onSpanEnd delegate when a span is discarded.

The discard method is now much simpler and more performant, as is the normal endSpan method.

_potentiallyOpenSpans and _networkSpans are now cleaned up whenever the app is backgrounded.

Testing

Making sure nothing is broken by this change is covered by existing E2E tests. Garbage collection of forgotten about spans was tested manually.

bugsnagbot commented 2 months ago

Build size impact

Format Size impact of Bugsnag (kB)
IL2CPP APK 4.1
IL2CPP IPA 2.25

Generated by :no_entry_sign: Danger