-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Leak in RCTNetwork module #19748
Comments
cc a couple folks that show up in the blame for the networking modules |
Pretty sure I'm seeing this on RN0.56 as well, though for some reason it's not showing up in the So far I've been able to largely alleviate the issue by getting rid of the |
I've figured out a workaround for my case. I'm using lodash's Simplified version of my updated code: const fetchResult = await fetch("http://domain.tld/path", input);
const text = await fetchResult.text();
const response = _cloneDeep(JSON.parse(text)); In my case, retaining the I think the React Native issue I am seeing concretely is that as of 0.55, retaining a I don't think this is the same issue as @yinghang initially reported, as their demo repo does not retain anything from the network request. |
I've opened #20352 for my issue. It turns out downloading a specifically-formatted tiny JSON file can cause a much bigger memory leak. Separately, I'm definitely able to confirm that OP's issue is still occurring in 0.56.0. The memory leak is much smaller, but still significant. |
Not too sure, will def give it a try when I have time. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
Environment
Description
A simple fetch call like the one below is enough to make various parts of
RCTNetwork
pile up references and memory allocations viamalloc
and etc. When I say pile up, what I mean is that everyGET
call is actuallymalloc
-ing and retaining some data that never goes away. Simulating a low memory warning in Instruments also doesn't seem to get these references garbage collected away.Reproducibility: 100%
Screenshot 1
Screenshot 2
Screenshot 3
Screenshot 4
Some of the more obvious locations that I observed to be leaking:
completionBlock
TLDR: I'm not too familiar with the inner workings with
RCTNetwork
but the memory allocation seems to suggest that something funky is going on with thecompletionBlock
which is leading to the retention of these references.This is also a continuation of the conversation we had in #19169. @oNaiPs, you might be interested in this. 😄
Reproducible Demo
Instruments
usingAllocations
RCTNetwork
related references pile upThe text was updated successfully, but these errors were encountered: