This course covers all aspects of garbage collection in Java, including how memory is split into generations and managed and how the different collectors do their job. We also cover the classes you can use to interact with the garbage collection, such as Soft, Weak, and PhantomReference.
Garbage Collection (GC) is a fundamental part of Java. Understanding how GC works is core to understanding how the Java Virtual Machine (JVM) works and will help you write better applications and to improve the performance of those applications. This course will look at all aspects of garbage collection, including looking at what 'young' and 'old' generations are, how the JVM moves objects between eden and survivor spaces, how memory is promoted into the 'old' generation, how different garbage collectors work, and how they affect the running of your application. We will also look at 'card tables' and how they help manage memory in the old generation. We will examine each of the garbage collectors including the serial and parallel collectors; the CMS collector and the G1 collector. We cover the tools you can use to monitor GC including jstat and VisualVM. Finally we look at ways you interact with the GC through classes Such as Soft, Weak, and PhantomReference and their associated helpers ReferenceQueue and WeakHashMap.
How Garbage Collection Works in the Oracle JVM Hi. My name is Kevin Jones and this is the How Garbage Collection Works in the Oracle JVM chapter from the Understanding the Java Virtual Machine Memory Management class from Pluralsight. In the previous chapter we talked about generalities of using a Garbage Collector. We now have to think about exactly how we're going to do this and exactly what the requirements are for a Garbage Collector, so there are many things to consider here. For example, with a Garbage Collector we have what are called stop the world events. A stop the world event is when the Garbage Collector pauses the entire application and, at that point, it collects garbage. We want to try and minimize these events. We also might need to think about Memory Fragmentation, so when the Garbage Collector runs does it defragment memory all at once, does it leave it to a later stage or does it just leave memory fragmented on the basis that leaving memory fragmented has a cheaper cost than trying to defragment it. We also have to think about the throughput of the Garbage Collector. How quickly can it run, how quickly can it collect garbage, and does that effect the behavior of your application? To achieve these things there are different Garbage Collector inside the virtual machines that are a mixture of generational Garbage Collector, that do copying, that do Mark and Sweep, some leave memory fragmentations, some don't, and you have to choose which one of these you'd like to use, and in this chapter we'll take a look at each of these different types of Garbage Collector that the virtual machine has and how they can be used inside the VM. One other thing to think about is if you're running on a multi-core machine, so now we have multiple processes, we have multiple threads, can we have a Garbage Collector that can run concurrently with our application, i. e. running parallel with the application, and will that provide benefits to the application? Again, Java provides these types of Garbage Collectors as well.
Garbage Collection Tools Hi. My name is Kevin Jones and this is the Garbage Collection Tools chapter from the Understanding the Java Virtual Machine Garbage Collection class from Pluralsight. In this chapter we'll take a look at a few of the ways we can monitor Garbage Collector inside Java. We'll look briefly at some of the management beans that are available and then we'll take a look at two of the tools that we can use to monitor GC, one called JStat and one called VisualVM alongside Visual GC.