6.2.1 Java memory management: garbage collection and allocation

Memory management, in its simplest terms, is nothing more than allocating and freeing memory. But of course it is much more than that. How allocation occurs and when and how collection of free objects occur can matter significantly when it comes to runtime performance.

The memory management component of the Java runtime environment is composed of the garbage collector and the allocator. The allocator allocates space for objects in a contiguous section of memory called the heap. The garbage collector frees up space in the heap when an object is no longer needed.