Skip to content
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

[Android] Very high memory usage. App becomes very laggy! #16590

Closed
kesha-antonov opened this issue Oct 29, 2017 · 19 comments
Closed

[Android] Very high memory usage. App becomes very laggy! #16590

kesha-antonov opened this issue Oct 29, 2017 · 19 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@kesha-antonov
Copy link
Contributor

kesha-antonov commented Oct 29, 2017

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:
dumpsys_without_remote_debugger copy

Here's memory usage with remote debugger turned on (see memory usage reduced):
dumpsys_with_remote_debugger copy

Even if I reduce views - memory usage is still high:
dumpsys_with_remote_debugger_reduced_views

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

  1. git clone https://github.com/kesha-antonov/rn_memory_usage_test_high_usage
  2. cd rn_memory_usage_test_high_usage
  3. npm i
  4. nano node_modules/react-native-sentry/android/build.gradle
  5. Change sdk tools to
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
  1. Set your android ndk, sdk paths in androids/local.properties
  2. react-native run-android
  3. adb shell dumpsys meminfo com.rn_memory_usage_test_high_usage
  4. See a lot of memory used (115 MB and above with just 21 (!!!) views, 125.5 MB with 126 useless views)

screen shot 2017-10-29 at 22 11 06

screen shot 2017-10-29 at 23 49 48

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

@kesha-antonov kesha-antonov changed the title [Android] Very high memory usage [Android] Very high memory usage. App becomes very laggy! Oct 29, 2017
@kesha-antonov
Copy link
Contributor Author

ezgif com-video-to-gif

@kesha-antonov
Copy link
Contributor Author

Anybody?

@javache @ide @hramos

@kesha-antonov
Copy link
Contributor Author

I even see growing memory in sample app #16600

@kesha-antonov
Copy link
Contributor Author

Maybe related #16732

@lhfiii
Copy link

lhfiii commented Dec 1, 2017

Resolved? How? @kesha-antonov

@kesha-antonov
Copy link
Contributor Author

Unfortunately now. Still very high memory usage @lhfiii

@lhfiii
Copy link

lhfiii commented Dec 5, 2017

@kesha-antonov It may be related with memory leak. Try to display a number of image with FlatList. Even close the activity does not help. Especially on android 4

@lhfiii
Copy link

lhfiii commented Dec 5, 2017

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.

@gold-duo
Copy link

YogaNodePool.get().clear(); release reference.

@kesha-antonov
Copy link
Contributor Author

Hello @droidwolf !
Where to put it?

@gold-duo
Copy link

activity onDestory

@pavanmehta91
Copy link

Could you guide where to put it? and where's Activity onDestory()?

@1c7
Copy link

1c7 commented Jan 31, 2018

still unsolved?

my RN 0.52 app also take huge chunk memory and then crash.
( on certain model of qihoo 360 phone, not all of them, it work fine on my Samsung Galaxy Note 5)

base on a screenshot user provide to me, it's this phone: 360 F4 Pro
https://www.androidheadlines.com/2016/04/360-mobile-introduces-the-360-f4-pro-handset-with-3gb-of-ram.html
not sure what cause the problem, I am not try to blame on the phone, just provide more info here.

my app use react-native-image-crop-picker to choose multiple image and display them with <Image> in a <FlatList>

I am still researching how to debug high memory usage problem.
I am not a Mobile developer(Android/iOS),
I am a Web Developer who don't want spend a lot time learning Mobile development,
that's why I chose RN.

@tehong
Copy link

tehong commented Feb 17, 2018

@kesha-antonov @droidwolf @1c7 @pavanmehta91
Has anyone resolved this problem. I also used react-native-image-crop-picker but I'm not sure that's related. My memory usage grows to 478MB from 250MB initially.

@1c7
Copy link

1c7 commented Feb 18, 2018

@tehong
nope,
I give up on this problem and decide not to waste more time on it.

I open an issue about this: #17801
and wrote demo app: https://github.com/1c7/react-native-image-memory-problem-demo-app
and a video using that demo app: https://youtu.be/Vgq-P826aqw

I am not an RN expert/mobile dev expert, so I can't solve this myself.
good luck with your project :D @tehong

@kesha-antonov
Copy link
Contributor Author

Same as @1c7

@kelset
Copy link
Contributor

kelset commented Mar 1, 2018

Hi folks, going to close this in favour of #13413, so that we avoid redundancy - the core team is aware of this Android+Flat/SectionList+Images issue (going to write a follow up there).

@kelset kelset closed this as completed Mar 1, 2018
@rahulnpadalkar
Copy link

@kesha-antonov which profiling tool is it. Looks really cool. Sorry new to react native.

@kesha-antonov
Copy link
Contributor Author

@rahulnpadalkar It's Android Studio

@facebook facebook locked as resolved and limited conversation to collaborators Mar 1, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants