FANDOM


Java has 3 types of memory

heap
non-heap
native 

[1]

Heap memory Edit

runtime data area from which memory for all class instances and arrays is allocated.

heap memory error example:

 java.lang.OutOfMemoryError: Java heap space

Loads of info on heap here; http://www.testing-software.org/tag/heap

Total Heap Edit

   Since collections occur when generations fill up, throughput is inversely proportional to the amount of memory available. Total available memory is the most important factor affecting garbage collection performance. [2]
   By default, the virtual machine grows or shrinks the heap at each collection to try to keep the proportion of free space to live objects at each collection within a specific range. This target range is set as a percentage by the parameters -XX:MinHeapFreeRatio=<minimum> and -XX:MaxHeapFreeRatio=<maximum>, and the total size is bounded below by -Xms and above by -Xmx . The default parameters for the 32-bit Solaris Operating System (SPARC Platform Edition) are shown in this table: 

Eden Space (heap) Edit

Initially, the Virtual Machine assigns all (most?) objects to the Eden Space.

Garbage collection occurs in each generation when it fills up (uses up its allotted memory); the VM performs a partial garbage collection (minor collection) on that memory pool to reclaim memory used by dead objects. The VM moves (promotes) any remaining objects from the Eden Space to one of the Survivor Spaces

Survivor space (heap)Edit

The VM moves objects that live long enough in the Survivor Spaces to the Tenured Space in the old generation.

Survivor Space (heap): The pool containing objects that have survived the garbage collection of the Eden space.



Tenured space (heap) Edit

Tenured Generation (heap): The pool containing objects that have existed for some time in the survivor space.

When the tenured generation fills up, there is a full GC (major collection) that is often much slower because it involves all live objects.

Non-heap memory Edit

method area and memory required for the internal processing of the JVM, or optimization of the JVM

java.lang.OutOfMemoryError: PermGen space


Permanent Generation Edit

(non-heap): The pool containing all the reflective data of the virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas.

Code Cache Edit

(non-heap): The HotSpot Java VM also includes a code cache, containing memory that is used for compilation and storage of native code.


other: Shallow Size Edit

permanent generation Edit

The permanent generation holds all the reflective data of the virtual machine itself, such as class and method objects.

Java VMs that use class data sharing, this generation is divided into read-only and read-write areas.


Code Cache Edit

Code Cache (non-heap): The HotSpot Java Virtual Machine also includes a code cache, containing memory that is used for compilation and storage of native code

native memory Edit

the virtual memory managed by the operating system

java.lang.OutOfMemoryError: request <size> bytes for <reason>. 
Out of swap space?



  1. http://docs.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html
  2. http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html#0.0.0.%20Total%20Heap%7Coutline