I made a simple app to test the memory of Android. It has two Activities, A and B. A is a simple Activity with a button that starts B. B consists of a pretty big image (jpg, 1024x768 pixel in mdpi)
When I monitor this process using DDMS, heap goes up as expected when moving from A to B.
When I press (hardware, or software using super.onBackPressed()
) button on B and end up in A again, the heap does not shrink again, even after calling garbage collection. Is this expected? Will the memory taken up by B ever be released during the lifetime of the process?
onBackPressed() just pop your B Activity from the BackStack then your Activity is no longer visible(onStop() called)to you, but it's process have'nt been killed untill the Os need it's memory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With