piątek, 22 marca 2013

JVM memory - loose speak

HEAP
  • young/new generation - includes new object space (Eden), and two survivor spaces.
    Eden - newly created objects are put here. Used to store objects with short time of life. 

    Survivor space -a pool containing objects that have survived 2-3 minor GC cleanings of the Eden space. If survivor spaces are too small the objects will be copied directly to old generation.
  • old/tenured generation. Larger than new generation, fills slower. 

PERM SPACE - contains meta data about classes and methods, String pool

STACK (LIFO) - store local variables and function calls. Lot lesser than heap space.
Each thread in Java has it's own stack. Object located in stack are visible only to it's thread. Objects put in heap are visible to all threads.

JVM arguments:
-Xms -> starting heap size
-Xmx -> maximum heap size
-Xmn -> size of new generation java heap space
-Xss -> thread stack size
-XX:MaxPermSize=256m -> max perm space size


Monitoring memory:
- jconsole
- jps and jstack