At the end of the process life cycle, all process memory (both a bunch of Java and C ++) will be freed and restored by the system. One thing, however, shutting down Android activity does not necessarily end the process. I am not sure that there is a policy of completing the process.
On the other hand, relying on garbage collection and completing () sounds like a solid design to me. You state: "Android does not guarantee finalize() ." Do you have a link to this? The reason is that in the case of rejection of "when the object is released as part of the completion of the process ...", we are still good.
And if you are super paranoid, you can write your own shell malloc () / free () / realloc (), save a list of all selected objects and enter a cleanup function that goes through the list and frees them all. However, the contained Java objects may end in a strange state of zombies, where memory is freed from under them. This is a complex proposal that is very easy to make a mistake. Therefore, I still say - believe in the garbage collector. The absence of this would be ... alarming.
source share