Skip to content

fix(android): fragment memory leak in RNSentryReactFragmentLifecycleTracer - #6599

Open
minhuwv wants to merge 2 commits into
getsentry:mainfrom
minhuwv:minhu/fix_react_fragment_lifecycle_tracer_memory_leak
Open

fix(android): fragment memory leak in RNSentryReactFragmentLifecycleTracer#6599
minhuwv wants to merge 2 commits into
getsentry:mainfrom
minhuwv:minhu/fix_react_fragment_lifecycle_tracer_memory_leak

Conversation

@minhuwv

@minhuwv minhuwv commented Aug 21, 2026

Copy link
Copy Markdown

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Resolve fragment memory leak by removing EventDispatcherListener added in onFragmentViewCreated after onFragmentViewDestroyed is called.

💡 Motivation and Context

Originally, we only remove EventDispatcherListener when received ScreenAppearEvent
this behavior cause Fragment memory leak.

If the Fragment is destroyed before the ScreenAppearEvent arrives, the listener will not be removed from the EventDispatcher. Because of this listener captures v, which is the Fragment's container view,
thereby retaining a reference to the Fragment and ultimately causing a memory leak.

image image

💚 How did you test it?

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

@minhuwv minhuwv changed the title Fix Fragment memory leak in EventDispatcherListener fix(android): fragment memory leak in RNSentryReactFragmentLifecycleTracer Aug 21, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bc02a80. Configure here.

@minhuwv
minhuwv force-pushed the minhu/fix_react_fragment_lifecycle_tracer_memory_leak branch from bc02a80 to 957fd6c Compare August 21, 2026 12:20
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.

1 participant