问题
(just to note I don't want to use pagination I want to load very large list)
I am using flatlist
to render about 5000 items.
Each item reference photo like this (not same photo just example):
256 × 256 PNG
30,759 bytes (30 kilobytes)
Or larger.
When I go over 1000 items I start to experience performance issues.
First is this realistic concern does image that is referenced from url go in to phone memory?
Is there better way to reduce memory pressure when load this amount of images?
I experience less performance problems on ios devices more on android.
回答1:
First is this realistic concern does image that is referenced from url go in to phone memory? Is there better way to reduce memory pressure when load this amount of images?
Yes your images most definitely go into phone memory, more specifically the the phone's RAM. You've already mentioned that you don't want to use pagination but that really is the best way to handle it in this case.
Another thing to consider would be to clear the image cache as you scroll past the images you no longer need. However React Native doesn't provider any such functionality out of the box. You would have to look into a third party caching solution such as https://github.com/billmalarky/react-native-image-cache-hoc
来源:https://stackoverflow.com/questions/49015211/does-load-large-amount-of-images-in-flatlist-hurt-performance-and-how-to-avoid-i