B
B
BitNeBolt2021-01-30 22:42:02
Android
BitNeBolt, 2021-01-30 22:42:02

Why does the used memory grow with each rotation?

When checking the used memory using the profiler, I rotated the phone, thereby creating a new activity. I did this with an open activity, which has only 2 buttons, and with an activity (opened by pressing a button from the first one), which has a ViewModel, a list of data in it, an object is created in the activity itself, to which the FragmentManager is passed.

The total memory usage on each rotation (both with the first and second activity) grew, but at a certain value it dropped back (dropped sharply). Of all the memory increases the most in the Native section, the Java section was almost constant (minor fluctuations). That is, judging by the documentation, the code that I wrote does not create problems? Why is growing what is classified as Native?

Java: Memory from objects allocated from Java or Kotlin code.


https://developer.android.com/studio/profile/memor...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-01-31
@BitNeBolt

It's just that the virtual machine eats memory, and at some point decides to free it, and garbage collection happens. So the description is ok. Unless after each garbage collection there is more unallocated memory than the last time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question