So I am trying to wrap my head around memory leaks in android and I am having a hard time understanding how it works. I understand the logic behind the memory leaks but when I try to play with it in android studio 3.0 profiler it gets weird.
For example: I assign activity to a static variable in oncreate and leave it there, then rotate the device 3 times. This should cause a memory leak but AS profiler show this.
I am not sure on how to interpret this but
1) why does only 1 activity instance has a depth and others don’t? After experimenting a little I figured out that if the instance has depth can not be garbage collected or am I wrong? Also when I initiate GC nothing changes for the first time and no activities gets GC’d and only after the second GC 2 other activities are gone.
2) So why no luck for the first time (same behaviour with normal activity without leaks) and how on earth did they get garbage collected if there is a reference to a static variable?