react-native
react-native copied to clipboard
fix fetch memory leak
Summary:
Root cause of the fetch memory leak:
The fetch requests store its result inside Blob which memory is managed by BlobCollector. On the JS engine side, the Blob is represented by an ID as JS string, and the GC don't know the size of the blob. So GC won't have interests to release the Blob.
Fix:
On iOS and Android, use setExternalMemoryPressure to acknowledge JS engine the size of Blob it holds.
Changelog:
[GENERAL] [FIXED] - fix fetch memory leak
Test Plan:
RepeatedlyFetch inside XHR example
This PR addresses issues #39100 #43647. @cortinico PTAL
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 19,478,635 | +91 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 22,851,235 | +148 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: 0383669a4b19289678ed75b28e38a74fabb01a64 Branch: main
@Sunbreak @NickGerleman @cortinico PTAL
@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Hi @NickGerleman, some facebook internal Lint/Check failed. Could you give me some guide to fix them?
@NickGerleman merged this pull request in facebook/react-native@c647950e5e78f1bcd110111067b21daa44e4d464.
This pull request was successfully merged by huzhanbo.luc in c647950e5e78f1bcd110111067b21daa44e4d464.
When will my fix make it into a release? | How to file a pick request?
nice, waiting for this improvement!
how about using libs fetching api like axios ?