Android 6: App uses more memory each time it’s started

In Android Studio, click Android Monitor at the bottom of your screen. Click the tab Monitors. You see a graph of the memory that your app uses. Now click the item Dump Java Heap which is next to the garbage van. The system starts collecting the info and creates a dump file. You can open the file in the Analyze Tasks tab in the upper right of your Android Studio window. Press the green arrow to find classes that leak memory. When you click a leaking activity, you’ll see a window Reference Tree. Go through the tree, finding the member that has depth zero. That’s the memory leak.

Analyse your code and images if anything wrong you are doing itself. Like very large images of drawables. make sure you correctly implement recycler or list views.
The following links may helpful to you.

  • Use leakcanary library to detect and make sure there is not leaks

  • Detect when user kill app from reccent apps

  • Invoke gc from memory monitor comes with Android Studio for correct value of memory usage cause gc not run frequently.

  • Use large heap size. <application android:largeHeap="true" in manifest

  • Use app context to start services
    startService(new Intent(getApplicationContext(),MyService.class));

Leave a Comment