-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
fix fetch memory leak #44336
fix fetch memory leak #44336
Conversation
This PR addresses issues #39100 #43647. @cortinico PTAL |
21ec3cb
to
005db2f
Compare
Base commit: 0383669 |
@@ -21,7 +21,7 @@ static void install(final ReactContext reactContext, final BlobModule blobModule | |||
new Runnable() { | |||
@Override | |||
public void run() { | |||
JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder(); | |||
JavaScriptContextHolder jsContext = reactContext.getCatalystInstance().getJavaScriptContextHolder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change might not be needed past #44360
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, change updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arushikesarwani94 Hi, PTAL again at the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @cortinico
005db2f
to
d1c98dd
Compare
@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 c647950. |
This pull request was successfully merged by huzhanbo.luc in c647950. 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 |
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 Pull Request resolved: facebook#44336 Test Plan: `RepeatedlyFetch` inside `XHR` example Reviewed By: javache Differential Revision: D57145270 Pulled By: NickGerleman fbshipit-source-id: afa53540e8563db4f9c6657f2dbbdff7bdfa66c0
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
insideXHR
example