Using MAT to Understand Android Memory Leaks -
i'm writing first app , trying understand how use mat find potential memory leaks. keep things simple, compiled default hello world app provided when starting new project in android studio, i.e.,
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } }
nice , simple. after launching app on tablet take heap dump (heap-conv-1.hprof) using ddms , hprof-conv
conversion tool. rotate tablet 20 times activity goes through number of life cycles, after take heap dump (heap-conv-2.hprof).
i load both heap dump files mat, compare them , regex .*mainactivity.*
. result is:
now there 7 instances of mainactivity
after rotations. since i'm not doing app, right in thinking purely because instances haven't been gc'd yet? in case , right in thinking android doesn't gc after orientation change, , when needs more memory?
for code not take of memory , doesn't leads leaks..application
takes lot memory when loading large number of bitmaps
memory or holding large number of objects.and using activity
context long lived objects..
here excellent video on memory leaks google developer.memory leaks
you know things after watching this..
Comments
Post a Comment