Android: delete / destroy objects when you rotate the screen

I find that performance degrades after one or more screen rotations, and I believe that this is probably due to the fact that the main activity of the application is destroyed and recreated every time the screen rotates, and that my application should leak memory when it happens.

I read that contrary to what might be expected, not all objects created by the main activity of the application (or in the classes called by this action) are destroyed when the activity is destroyed. In particular, I think I read (although now I can’t find where) that if View uses a large bitmap object, then the Activity onDestroy () method should be overloaded and the bitmap should be explicitly processed.

Are there other objects that need to be destroyed or deleted when the Activity is destroyed? What about listeners? Is there a comprehensive tutorial or guide on this?

+3
source share
2 answers

Is there a comprehensive tutorial or guide on this topic?

Not really.

Are there other objects that will be destroyed or deleted when the Activity is destroyed? What about listeners?

Bitmap images are unusual, in part because they use memory outside the 16 MB heap if I understand the Byzantine Android-style memory model correctly.

, , , - , . , , , , . :

  • (, , , ).
  • (, ).
+5

, android:configChanges="orientation" Activity . , ! ( Ribo , .) ​​

+1

Source: https://habr.com/ru/post/1729894/


All Articles