Is an inner class declaration dangerous?

I read the official Android technical article: "how to avoid memory leaks ?" . It is said that creating inner classes in the Activity class is dangerous, but what about creating an inner class inside the View class: is the leak the same or worse?

+4
source share
1 answer

If you create classes with a life cycle of nothing more than a lookup, that's fine. Otherwise, you should avoid this.

If you use such a structure, make sure that you do not have references to instances of the inner class when viewing is not needed. Then the GC will collect everything and there will be no memory leaks.

+4
source

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


All Articles