Reputation: 5392
I've read the official Android technical article: "how to avoid memory leaks ?"
. They say that creating inner classes in an Activity
class is dangerous, but what about creating inner class inside a View
class : is the leak danger the same or worse ?
Upvotes: 4
Views: 216
Reputation: 8612
If you create classes with lifecycle not more than view - it's OK. Otherwise you should avoid doing this.
If you use such structure - be sure, that you do not have any links on instances of inner class, when view is not necessary. Then GC will collect everything, and there will not memory leaks.
Upvotes: 4