Reputation: 31
I'm running my project build on React-Native on android device and as I scroll down the list the app memory continuously increases. Even after navigating to other screen, the memory is not freed up in case of android while a lot of memory is freed in case of ios device. The investigation for the android was done on the android activity monitor and the video for same is available here
How can the memory be freed up in case of android ?
Upvotes: 1
Views: 2107
Reputation: 15719
That's the standard behavior of the Android library Fresco used by React Native under the hood. Fresco caches all images in memory to the max authorized by the system. It's a cache, so images stay in memory even if they are removed from the screen, just in case, for later use.
When the app needs memory space, the GC is able to "scrap" this cache. That's what happen at 0'24'' in your screen recording (you can see a small "drop" of the allocated memory).
This article explains the memory management in details.
In conclusion, a React Native app using images will always use almost all the memory allowed by the system. The memory is gradually freed for the needs of the app.
Upvotes: 2
Reputation: 2709
At the moment there are known issues with react native ListView, check the issues related to listview here https://react-native.canny.io/feature-requests/p/fix-various-listview-issues. In the interim check this repo that tries to optimise listview for performance https://github.com/sghiassy/react-native-sglistview
Upvotes: 0