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.
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.
- Java Garbage Collection, Monitoring and Tuning Carol McDonald presentation about Garbage Collection, monitoring and tuning.
- Using JConsole Official JConsole documentation.
- How to Handle Java Finalization’s Memory-Retention Issues DevX article about how to effectively manipulate objects finalization.
- Weak references: do you know what is it? - Java Magazine #99 Article about weak references published on Java Magazine #99.