How does using a static inner class prevent memory leaks?

I read that a non-static inner class can make more memory leaks than a static inner class. The good thing is that a non-static class will generate an instance of an object as well as its class as a reference to it.

In this way, a static inner class can avoid multiple object instances since it will create a single class level object rather than an instance level. But how can you avoid creating instances of your outer class?

Plz helps to understand static inner class vs non-static / anonymous inner class memory leak.

+3


source to share





All Articles