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

Construct hint items lazily #2632

Merged
merged 1 commit into from
Sep 19, 2023
Merged

Construct hint items lazily #2632

merged 1 commit into from
Sep 19, 2023

Conversation

jamescrosswell
Copy link
Collaborator

@jamescrosswell jamescrosswell commented Sep 18, 2023

#skip-changelog

Related to #2607 (comment)

In applications that use breadcrumbs heavily, the biggest memory hog is Dictionary<string,object?>. The following is a snapshot from a memory profile of an app that's creating lots of breadcrumbs:
image

Most of those are unnecessarily created by the Hint constructor. By delaying instatiation of Hint.Items until they're actually used, we can avoid most allocations.

Results

Saves about (752B - 672B) / 752B = 10.64% of memory allocated for breadcrumbs.

Note: The savings scale linearly from individual breadcrumbs to hundreds of breadcrumbs (although savings for breadcrumbs in particular will be capped per Transaction by SentryOptions.MaxBreadcrumbs.

Before

image

After

image

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