Tracking the creation of objects in Android DDMS, VM from memory

Hey, I'm new to Android and kindly correct if I'm wrong: I'm trying to control the number of objects created and a bunch (which obviously depends on the number of objects) through DDMS. During this, if I run the application, I have "n" no. created object. Pressing the return button will not necessarily call the Destroy () function, and therefore the number of objects will still be "n". Now that I have started the application again, onCreate () will be called again and these "n" objects will be created again (now the total number of objects will be greater than "n"). Thus, repeating this process (restarting the application) will lead to a continuous increase in the number of objects? (which obviously should not be)

+4
source share
1 answer

The number of objects will increase as they are created, and then decrease as the garbage collector starts.

If the number of objects continues to increase even when garbage collection, you may have a memory leak. A dump of the "hprof" heap (when it can be started by clicking a button in DDMS) can help determine the cause.

+1
source

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


All Articles