-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Memory Leak on iOS: FastImage not released from memory when callbacks onLoad is set #371
Comments
Sounds like a good idea to me 🤷♂️ |
Ok sorry for the delay, I did the fix on my fork not long after opening this issue, but I forgot to submit the PR. Now it's done I submitted the PR. |
Hello @StevenMasini, I have tried your PR but it does not compile. (as I reported you in the PR) Thank you, |
@marf Hey sorry for the delay. I am working on it since yesterday. I found a very fast and easy way to reproduce the memory leak. When you set the Also I am sorry for the fix I submitted earlier, it's been a while that I haven't done Objective C, so I forgot that So the correct syntax for the fix I submitted is But still, that's not enough to fix the memory leak. So I will keep investigating. |
HI @StevenMasini , if the |
@truongluong1314520 You can set the
For instance do onError={() => {
// your implemention
}} but don't onError={error => {
// this will create a memory leak
// the same for every callback who doesn't pass parameters, just strictly follow the documentation
// don't try to retrieve parameters who doesn't exist
console.log(error)
}} |
I made a new Pull Request here #433 |
I would be happy if people could try my PR #433. It should fix the memory leak on iOS. Let me know if it works for you or not ? |
Hello @StevenMasini I will try your PR #433 , thank you! I will try your PR #433 hoping memory usage decreases. Thank you |
@marf Actually not only the It's good to reduce the resolution of your pictures, you probably didn't do it for nothing. |
@StevenMasini thank you! |
faced the same issue and had to remove the onError callback. Is there a fix coming for this? |
@manithin What was your implementation of I remember that if you try to do this, it will lead to a memory leak. onError={(error) => { ... }} If so then just remove the param. |
This is how i implement it. Just set an error status for displaying a default image. onError={() => setImageError(true)} when this block was disabled, there were immediate changes in the performance. |
Heyy...@StevenMasini I am also facing same crash issue on ios. I want to user you PR. But don't know how can I use your PR. I don't know much more about git. I just installed fastimage from npm. Can you please tell me how I can use it ? |
@kishanbharda But if you are experiencing issues with image loading, etc. My branch still fix more issues. You can modify your
Also, I keep that branch up to date with the main repository. |
Thank you. I will try. |
An engineer at my company noticed a memory leak on iOS when the props
onLoad
is set on iOS.FastImage doesn't get released when it should be.
After investigating the source code, I found out that using a
strong
reference toself
to callsendOnLoad
insd_setImageWithURL
.I suspect this line to be the cause of this memory leaks.
react-native-fast-image/ios/FastImage/FFFastImageView.m
Line 167 in 141a4a0
I can submit a Pull Request to transform this
strong
reference into aweak
reference, which should fix the memory leak.The text was updated successfully, but these errors were encountered: