Monday, April 9, 2012

JVM memory model 101

    Young Generation
        Eden space, two Survivor (From/To) spaces                   
    Old Generation
        Tenured space
Non-Heap (Perm + C-Heap)
    Permanent Space
    Class files and jar files
    Code Generation
    Socket Buffers
    Thread stacks
    Direct Memory Space
    JNI Code
    Garbage Collection
    JNI allocated memory

Space Allocation
-Xmx -Xms -Xmn -Xss
Young size(-XX:NewRatio)
Survivor Ratio(-XX:SurvivorRatio)
-XX:PermSize=<value> (initial)
-XX:MaxPermSize=<value> (max)

Concurrent/Parallel Garbage Collection Settings
Parallel GC in the New(Young) Generation
Concurrent in the Old generation
Use these two combined
Multiple CPU box can take advantage of this

More GC Settings:


Update 4/25/2012
Java classes are stored in the permanent generation. What all does that entail? Besides the basic fields of a Java class there are
  • Methods of a class (including the bytecodes)
  • Names of the classes (in the form of an object that points to a string also in the permanent generation)
  • Constant pool information (data read from the class file, see chapter 4 of the JVM specification for all the details, including static fields)
  • Object arrays and type arrays associated with a class (e.g., an object array containing references to methods)
  • Internal objects created by the JVM (java/lang/Object or java/lang/exception for instance)
  • Information used for optimization by the compilers (JITs) 

1 comment: