Skip to content

Conversation

@Flash0ver
Copy link
Member

@Flash0ver Flash0ver commented Nov 10, 2025

Fixes #4709

Similar to #3432,
but for the newer types UnsampledTransaction and UnsampledSpan.


With the reproduction code from the related issue (see #4709):

Before
image

After
image


Also verified against Sentry.Samples.AspNetCore.Basic:

  • Memory-Profile keeps stable
    • with and without options.AutoRegisterTracing = false;
    • with options.TracesSampleRate = 1.0; and options.TracesSampleRate = 0.0;
  • The SentryTracingMiddleware is already finishing the Transactions, hence now also releasing the tracked Spans

@Flash0ver Flash0ver self-assigned this Nov 10, 2025
@Flash0ver Flash0ver changed the base branch from main to version6 November 10, 2025 15:12
@Flash0ver Flash0ver marked this pull request as ready for review November 10, 2025 15:34
@Flash0ver
Copy link
Member Author

@sentry review

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (version6@522f80e). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             version6    #4717   +/-   ##
===========================================
  Coverage            ?   73.26%           
===========================================
  Files               ?      480           
  Lines               ?    17432           
  Branches            ?     3439           
===========================================
  Hits                ?    12771           
  Misses              ?     3815           
  Partials            ?      846           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

private void ReleaseSpans()
{
#if NETSTANDARD2_1_OR_GREATER
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
Copy link
Member Author

@Flash0ver Flash0ver Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: use Clear on .NET Core and .NET TFMs as well

Previously, only netstandard2.1 was using Clear.
But the ConcurrentBag.Clear Method is also available since netcoreapp2.0, and with that, also since net5.0.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@jamescrosswell jamescrosswell merged commit dcb8bd7 into version6 Nov 11, 2025
30 checks passed
@jamescrosswell jamescrosswell deleted the fix/unsampled-memory-leak branch November 11, 2025 21:12
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.

Memory leak/issues with UnsampledTransactions in 5.9.0

3 participants