Skip to content

Conversation

@WoLewicki
Copy link
Member

@WoLewicki WoLewicki commented May 9, 2025

Description

Right now, when removing React Native instance in brownfield apps, the ScreensModule cpp side is kept in memory until the whole app is killed. This code removes global ref when invalidating the module too. It fixes memleaks e.g. in Expensify App.

Changes

Test code and steps to reproduce

You'd need brownfield app so no repro attached. Try remove and add RN instance to native android app a couple of times, then do a heap dump in AS and check for ScreensModule instances with 0 depth in its references.

Checklist

@WoLewicki WoLewicki requested a review from kkafar May 9, 2025 13:23
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

makes sense, thanks.

@kkafar kkafar added the Backport to v3 This PR / PR resolving this issue should be backported to v3 line of the library label May 9, 2025
@kkafar kkafar merged commit 5b482bc into main May 9, 2025
5 checks passed
@kkafar kkafar deleted the @wolewicki/remove-global-ref-on-invalidate branch May 9, 2025 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport to v3 This PR / PR resolving this issue should be backported to v3 line of the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants