Persistent issues
Even with the advent of Java 9, there were downsides to Java's garbage collection system. Because it is an automatic process, we do not have complete control of when the collector runs. We, as developers, are not in control of garbage collection, the JVM is. The JVM makes the decision when to run garbage collection. As you have seen earlier in this chapter, we can ask the JVM to run garbage collection using the System.gc()
method. Despite our use of this method, we are guaranteed that our request will be honored or that it will be complied with in a timely manner.
Earlier in this chapter, we reviewed several approaches and algorithms for garbage collection. We discussed how we, as developers, can take control of the process. That assumes that we have the ability to take control of garbage collection. Even when we specify a specific garbage collection technique, for example using -XX:+UseConcMarkSweepGC
for CMS garbage collection, we are not guaranteed that the JVM will use...