Garbage collector

= Garbage Collector =

One of the most known facts about Java is that it uses all the memory available. Taking into account that Java doesn't use pointers to memory and that we allocate objects dynamicaly every time we use the _new_ operator, Java needs an artifact to destroy (or de-allocate) automatically all these no longer needed objects so others newer can use their memory slices, else we would have a _very_beautiful_ memory leak. That's the Garbage Collector. In languages like C, it's the programmer responsability to de-allocate memory used by using the free function.

So we can divided the objects into these categories:
 * Young Generation: Recently created objects.
 * write barrier: Everytime an object in the old generation references an object in the new generation it's recorded in this table so the Garbage Collector determines wherer or not it's subject for deletion.
 * Eden Space: Most of the newly created objects are located here. After a garbage collection the surviving objects are moved to the first Survivor Space.
 * Survidor Space: Ee can find 2 survivor spaces. Once it's full, surviving objects are moved to the other Survivor Space. Once it's full, surviving objects are moved to the other Survivor Space. And finally surviving objects are moved to the Old Generation.
 * Old Generation: Young generation promotes into this category.
 * Serial GC:
 * Mark-sweep-compact
 * Parallel GC:
 * Throughput GC.
 * Parallel Old GC (Parallel Compacting GC): mark – summary – compaction
 * Concurrent Mark & Sweep GC (or "CMS").
 * Garbage First (G1) GC.
 * Permanent Generation: Classes or interned character strings.

Memory Allocation in HotSpot:
 * Bump-the-pointer:
 * TLABs (Thread-Local Allocation Buffers):

We can tune it as [Oracle describes].

To see all the JVM options:

http://jvm-options.tech.xebia.fr/

http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/b92c45f2bc75/src/share/vm/runtime/globals.hpp

http://code.google.com/p/java-allocation-instrumenter/