Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My android app consume a lot of memory

My app is consuming a lot of memory I have used the following app to measure my app memory consumption

https://play.google.com/store/apps/details?id=mem.usage&hl=en

can any one tell me how can I optimize the memory used by my app?

like image 538
Amira Elsayed Ismail Avatar asked Jan 01 '26 03:01

Amira Elsayed Ismail


1 Answers

1) you can use LeakCanry for optimize memory. leakCanry will give you report for each individual leaks or when multiple instance of an activity will be on stack.

here is more info and integration guide https://github.com/square/leakcanary

2) you can check android studio memory monitor for your app's memory use. from that graph you can check when GC is being called and which activity or function is taking more memory so you can optimize through it.

more info regarding this http://developer.android.com/tools/performance/memory-monitor/index.html

3) i have gone through udacity tutorial and videos. you can see how to improving rendering for your layouts

  • Need to reduce unnecessary views.
  • dont apply unnecessary background.

more stuff https://www.udacity.com/course/android-performance--ud825

4) one more important thing use ApplicationContext where you can use it because Activity context keeps in stack and wont be eligible for GC until that context related task is being finished.

like image 184
Sanket Kachhela Avatar answered Jan 03 '26 15:01

Sanket Kachhela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!