Tuesday, January 27, 2015

Android App Memory Management


  • Android App heap size is device dependent.
      • ActivityManager.getMemoryClass() - returns default app heap size.
  • Large Heap
    • Use largeHeap to increase app heap memory. But it degrades app performance, Because GC pause time will be more in large heap.
                <application
                     android:name="com.example.foobar"
                     android:largeHeap="true"
                      ...
                </application>

                ActivityManager.getLargeMemoryClass() - API to know large heap size.

  • Interpreting GC Logcat Messages
                D/dalvikvm( 9050): GC_CONCURRENT freed 2049K, 65% free 3571K/ 9991K, external 4703K/5261K, paused 2ms+2ms

                 GC Reason:
                 GC_CONCURRENT: GC tries to reclaim unused app heap memory when app     heap memory usage increase. This operation porformed in new thread, Sc GC pause time is very less in concurrent GC operation.
                 GC_FOR_MALLOC:
                 GC_EXTERNAL_ALLOC:
                 GC_HPROF_DUMP_HEAP: 
                 GC_EXPLICIT: System.gc() call triggers explicit GC for the application.

             freed 2049K -> Amount of Heap freed.
                65% free 3571K/ 9991K -> Heap statistics.
                external 4703K/5261K -> Bitmap / Native memory statistics.
                paused 2ms+2ms -> GC pause time.
                 





0 comments:

Post a Comment