-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[expo-image] When many image is rendered RAM usage goes over 2000mb and app crashes #26781
Comments
Confirm! I have same issue and RAM usage goes beyond 6gb, Image component imported from react-native perform properly. |
Do you know at how many images it occurs? |
It can be flatlist or flash |
Thx for the warning. Was looking at this since expo 50 broke react-native image for me. I guess I need to debug it more 😃 |
Yeah, for some reason simple image from react-native has issues with prefetch on iOS for example. |
Any info on this issue so far? |
No, this issue is being ignored for some reason... |
@brentvatne can you help us please? |
So I sent mail to @brentvatne and here is his response: hey george, could you copy all of those images directly to the repository that you shared there so we can inspect them more easily? best, @Miigaarino can you do this? |
Thank you for filing this issue! |
the app does not crash for me but i do see the memory usage spike briefly before recovering. i asked for the images because it would be easy to assess how large each of them are / if there are any big outliers when they are on disk rather than at a url where i would need to open each one to determine the size Screen.Recording.2024-03-11.at.10.55.00.AM.mov |
i spoke with @tsapeta about this and he went through the trouble of looking at the images to determine if they could be the cause, he found some that are extremely large and would cause this issue, eg: https://assets-us-01.kc-usercontent.com/6c08ae22-aaba-00c5-2884-7221a976fac0/16abfdeb-34a3-4f47-9764-b72409d9ea44/Innovation%20Experts.jpg - this is a 1.9mb image (reasonable) but its dimensions are 22433 × 6125 (not reasonable). i would suggest ensuring that you use appropriately sized images for the device. we have a couple ideas to help here:
|
So sorry i didn't pay attention for the notifications also for the late reply @GeorgeHop, @brentvatne |
@Miigaarino - you could use an image cdn to process the images and serve them if you don't control the source. you could serve a device appropriate sized image and the user would not need to use as much data or memory. if each of those images averages to 500kb and you load 175 then that would be 87.5mb, you could reduce that significantly by serving an image tailored for the device. https://web.dev/articles/image-cdns |
@GeorgeHop Would you be able to provide a simple reproducible example? It looks like your use case (and repro) might be different than the one provided in this issue.
In the provided example, the problem is that the exact same image (22433 × 6125) is downloaded at least three times from different URLs. The URL is the cache key, so they are basically stored on the disc and memory separately. The overall Increased memory consumption with Besides using too big images, the problem in expo-image I do see here is the spike for a short period of time when the images are being downscaled. |
Okay, I will make a little bit more tests... |
Thanks to everyone who trying to help with this 😇 |
I tried both expo-image and faster-image in a gallery view that renders 100+ images with a size of 1920x1080, 1MB each. I wonder why the memory spike is so high. It reaches 2GB for 100 images, which is 20MB per image. Also, I have a question if just throttling the image loading helps in this case. In my case which renders 100+ images but in a smaller size as thumbnails, so caching the resized images would be helpful. |
We were experiencing issues using FlashList (yes we used |
Minimal reproducible example
https://github.com/Miigaarino/expo-image-memory-issue
Summary
Example below is after rendering images on newly created application.
To test:
expo-image.MP4
Environment
The text was updated successfully, but these errors were encountered: