Avoid memory leaks in inner classes

If you’ve read my Java 101 tutorial introducing static classes and inner classes, you should be familiar with the basics of working with nested classes in Java code. In this associated tip, I’ll walk you through one of the pitfalls of nesting classes, which is the inner class’s potential for causing a memory leak and out-of-memory error in the JVM.

This type of memory leak occurs because an inner class must at all times be able to access its outer class–which doesn’t always work with the JVM’s plans.

Getting from a simple nesting prodedure to an out-of-memory error (and possibly shutting down the JVM) is a process. The best way to understand it is by watching it unfold.

To read this article in full, please click here

\"IT電腦補習
立刻註冊及報名電腦補習課程吧!

Find A Teacher Form:
https://docs.google.com/forms/d/1vREBnX5n262umf4wU5U2pyTwvk9O-JrAgblA-wH9GFQ/viewform?edit_requested=true#responses

Email:
public1989two@gmail.com






www.itsec.hk
www.itsec.vip
www.itseceu.uk

Be the first to comment

Leave a Reply

Your email address will not be published.


*