react-native: [Android] Very high memory usage. App becomes very laggy!
Hello! I have an app with not very complex UI. But with lots of code. And it takes a lot of memory in android. And becomes very laggy after few screens loaded. In iOS code works without any lag in dev/prod modes.
Is this a bug report?
Yes. In iOS same code works great whether is in dev mode or production mode.
Here’s memory usage without remote debugger turned on:
Here’s memory usage with remote debugger turned on (see memory usage reduced):
Even if I reduce views - memory usage is still high:
Have you read the Contributing Guidelines?
Yes.
Environment
Environment: OS: macOS High Sierra 10.13 Node: 6.11.3 Yarn: Not Found npm: 5.4.2 Watchman: 4.9.0 Xcode: Xcode 9.0 Build version 9A235 Android Studio: 2.3 AI-162.3871768
Packages: (wanted => installed) react: ^16.0.0 => 16.0.0 react-native: github:facebook/react-native#60c898d8643daf80ef8175af7dc8411709eff379 => 1000.0.0
RN - 0.50-rc
Steps to Reproduce
git clone https://github.com/kesha-antonov/rn_memory_usage_test_high_usage
cd rn_memory_usage_test_high_usage
npm i
nano node_modules/react-native-sentry/android/build.gradle
- Change sdk tools to
compileSdkVersion 25
buildToolsVersion '25.0.3'
- Set your android ndk, sdk paths in
androids/local.properties
react-native run-android
adb shell dumpsys meminfo com.rn_memory_usage_test_high_usage
- See a lot of memory used (115 MB and above with just 21 (!!!) views, 125.5 MB with 126 useless views)
Expected Behavior
25-75 MB of memory usage will be fine I guess. With no lags, no frame drops
Actual Behavior
A lot of memory used: 165-261 MB Users experience good look of first screen and when they go through the app it becomes laggy
Reproducible Demo
https://github.com/kesha-antonov/rn_memory_usage_test_high_usage
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 19 (8 by maintainers)
I have replace fresco with glide and the leak still exists. It seems that the leak comes from other native module. I have found a lot of YogaNode in the FinalizeReference chain.