Skip to content

fix: call delete instead of free in imagefetcher #51492

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WoLewicki
Copy link
Contributor

Summary:

I've been digging into memleaks in RN for some time and noticed that instances of FabricUIManager are leaking on reload action even on an empty app. I managed to pinpoint it to ContextContainer (which holds FabricUIManager on the cpp side) not being deallocated after reload. After much much digging (since contextContainer is passed around in many places) I found that destructor of ImageFetcher never runs on reload, and its instance holds contextContainer. It turns out that ImageManager, which holds ImageFetcher, was calling free instead of delete and the former does not call destructor. After applying it, contextContainer does not leak making FabricUIManager instances not to leak too 🎉.

Changelog:

[ANDROID] [FIXED] - Change free to delete to call destructor of ImageFetcher and release contextContainer.

Test Plan:

Run empty RN app in AS, do reload multiple times and see in AS profiler that instances of FabricUIManager are kept in memory without this change.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Software Mansion Partner: Software Mansion Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels May 21, 2025
@javache
Copy link
Member

javache commented May 21, 2025

Great find!

@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Software Mansion Partner: Software Mansion Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants