Does load large amount of images in flatList hurt performance and how to avoid it

杀马特。学长 韩版系。学妹 提交于 2019-12-13 04:45:38

问题


(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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!