Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android, back button deallocates Activity memory?

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?

like image 667
Jonny Avatar asked Oct 05 '22 05:10

Jonny


1 Answers

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

like image 153
Arash GM Avatar answered Oct 10 '22 02:10

Arash GM