tool to check memory leaks in android
Tool "Traceview" will also be helpful to you. This comes with the android sdk.
Refer to the following link for more detail.
http://developer.android.com/guide/developing/tools/traceview.html
https://developer.android.com/studio/profile/traceview.html
How to detect memory leak
This might be useful.
What Android tools and methods work best to find memory/resource leaks?
Android memory leak?
Here are a couple of articles and posts, which probably help you to get on the right track:
Allocation tracker, which comes with Android SDK is very useful. Read Romain Guy's articles. It helped me to track down pretty nasty leaks. It also helps you to write better software. E.g. I learned to create less objects, use more StringBuilder, and cache a lot more:
What Android tools and methods work best to find memory/resource leaks?
Sometimes your app is just so messed up that you have to re-design it in the whole. Here are official, good hints for that (my favourite is the Avoid Creating Unnecessary Objects):
http://developer.android.com/guide/practices/design/performance.html
Here's an excellent article about attacking your memory issues:
http://ttlnews.blogspot.com/2010/01/attacking-memory-problems-on-android.html
Official article about avoiding memory leaks:
http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html
Read also this: tool to check memory leaks in android
Others already pointed about bitmaps. Here's an article describing the issue: http://zrgiu.com/blog/2011/01/android-bitmaps-and-out-of-memory-errors/
Memory Analyzer Tool in android?
- Open DDMS perspective in Eclipse.
- Select Devices tab.
- Choose a process you want to make a dump for.
- Click Dump HPROF file button. The dump will be made and MAT window will be opened, assuming MAT is installed.
- Choose Leak Suspects Report in the wizard window and click Finish.
That's all. You'll se a list of possible leaks, but some of them are false-positive. I recommend you to run an activity you want to check leaks in several times and then run MAT again.
how to do memory and CPU time profiling in Android
You can use DDMS http://developer.android.com/guide/developing/debugging/ddms.html, Open it in eclipse and generate a heap dump to view it in Eclipse memory analyzer.
Detect memory leak in android native code
You load *.so library with System.loadLibrary
, than call any jni functions. So you can define "startup" and "cleanup" functions - you can do your initialzation in former func and release all resources in latter. In this case it's possible to use any from large amount of available leak tracers - for example you can see following:
http://dmalloc.com/
http://www.andreasen.org/LeakTracer/
http://memwatch.sourceforge.net/
http://mpatrol.sourceforge.net/
About valgrind: https://stackoverflow.com/a/7815977/814297
Memory Management in Android
It sounds like you need to check out the "Allocation Tracker" tool, which is available in the "DDMS' Perspective in eclipse.
This will show you exactly which data structures are consuming memory.
Related Topics
How to Make a Phone Call in Android and Come Back to My Activity When the Call Is Done
Android Create Shortcuts on the Home Screen
Android - Android.View.Inflateexception: Binary Xml File Line #8: Error Inflating Class Fragment
CSS Media Query - Soft-Keyboard Breaks CSS Orientation Rules - Alternative Solution
Perform a Task on Uninstall in Android
How to Disable Gradle 'Offline Mode' in Android Studio
How to Change Color of Button in Android When Clicked
Android Open and Save Files To/From Google Drive Sdk
How to Make Bitmap Compress Without Change the Bitmap Size
Onitemclicklistener Not Working in Listview
Dialog With Transparent Background in Android
Offline Speech Recognition in Android (Jellybean)
Programmatically Switching Off Android Phone
Disable Scrolling in All Mobile Devices
...Have You Declared This Activity in Your Androidmanifest.Xml