Choosing a Garbage Collector
You might wonder why the JVM has all these different types of memory. Why not just put all objects in one place?
The JVM segments memory to make garbage collection faster, which improves overall performance. When it comes down to it, this is the same reason you might choose a Hash instead of an Array. Having different sections of memory allows the GC to find things faster and run less often. Optimizing the GC in this way is important because when the GC runs, your application pauses. Garbage collection must happen quickly and as infrequently as possible.
In general, a garbage collector is form of automatic memory management. It finds objects that are no longer in use and releases the memory associated with those ...