Just a few facts and terms (which I tend to forget or mix up):
The Sun-JVM process memory consists of the “Permanent Space” and the “Heap".
The Permanent Space (aka Permanent Generation) holds the bytecode of all loaded classes.
java.lang:type=MemoryPool,name=PS Perm Gen
The “generational” Heap is divided into “Old Generation” and “Young Generation".
The Old Generation (aka Tentured Space) contains long-lived objects and is cleaned only during a major garbage collection.
java.lang:type=MemoryPool,name=PS Old Gen
The New Generation (aka New Space) is subdivided into “Eden” and two Survivor Spaces named “From Space” and “To Space".
Eden is for new and short-lived objects. Initial size is usually 32MB or 64MB, may be overwritten with
- From Space and To Space contain objects that have survived a minor garbage collection. Initial size is usually 1MB or 2MB each, may be overwritten with
A Minor Collection (aka Copy Collection) cleans up Eden and moves the remaining objects up to the survivor spaces (and later into the tentured space)
A Major Collection (aka Stop-the-World Collection, aka Mark-and-Sweep, aka Mark-Sweep-Compact) is executed when a minor collection cannot reclaim enough memory (which should not occur more often than twice an hour) . It cleans up the whole heap (the young generation is empty afterwards).
The available collectors are:
Serial Collector (default on Client-VM)
Parallel Collector (aka Throughput Collector, default on Server-VM)
Parallel Compacting Collector
- Concurrent Mark-Sweep Collector (aka Low-Latency Collector)
(Note: all data refer to Java 6)
Recommended memory sizes (Steven Haines, Java 5):
- Hint: allocate the heap at once (i.e.
-Xms1024m -Xmx1024mfor a 1GB heap)
- Young generation: a little less than half the heapsize (i.e.
-XX:NewSize=448m -XX:MaxNewSize=448mfor a 1GB heap)
- Each survivor space: 1/8 of the young generation (i.e.
- Permanent space: start with 128MB, max 256MB (i.e.
-XX:PermSize=128m -XX:MaxPermSize=128m) - this value is not part of the heap!