Understanding and optimizing the Garbage Collection - Part 3 [pt]

In April, 2012 I published an article (in Portuguese) in Java Magazine #104, about common problems in Java code which ignore how Garbage Collection operates, how to write code to optimize this process and how to analyse the heap memory status in runtime.

Article Understanding and optimizing the Garbage Collection - Part 3 - DevMedia

Summary

The article begins by reviewing JVM options to log the Garbage Collection process activities as well presenting the JConsole tool for a picture of the heap memory situation. Next, states about memory leaks and shows an example of a code with this problem, analysing its runtime execution on JConsole. Lastly, presents other subjects as the finalize() method, weak references and concludes suggesting some good practices.

When is the subject useful

The subject is very relevant to any Java developer, even though the consequences of a badly configured Garbage Collection process won’t be much evident in development environments, certainly will make the difference in production environments. It is important to understand the reasons that cause malfunctioning of the Garbage Collection and how to avoid those scenarios, using good practices for such.