JVM memory areas / components
- Heap area
Objects and array stored
Created when JVM started define fix size or vary between min and max size –Xms -Xmx
Yong Generation
Eden Memory
Survivor Memory
Most of the newly created objects are located in the Eden memory space.
When Eden space is filled with objects, Minor GC is performed and all the survivor objects are moved to one of the survivor spaces.
Old Generation
after many rounds of minor GC object is moved to the Old generation space.
-- Perm Gem :
Permanent Generation or “Perm Gen” contains the application metadata required by the JVM to describe the classes and methods used in the application. Note that Perm Gen is not part of Java Heap memory.
- Method area and runtime constant pool
field, method data, code, constructor ,
created on JVM started its part of Heap Memory
The method area may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger method area becomes unnecessary
- JVM stack
Each of the JVM threads has a private stack created at the same time as that of the thread. The stack stores frames. A frame is used to store data and partial results and to perform dynamic linking, return values for methods, and dispatch exceptions.
If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError.
f Java Virtual Machine stacks can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, or if insufficient memory can be made available to create the initial Java Virtual Machine stack for a new thread, the Java Virtual Machine throws an OutOfMemoryError.
- Native method stacks
Native method stacks is called C stacks; it support native methods (methods written in a language other than the Java programming language), typically allocated per each thread when each thread is created. Java Virtual Machine implementations that cannot load native methods and that do not themselves rely on conventional stacks need not supply native method stacks.
The size of native method stacks can be either fixed or dynamic.
- PC registers
-- Memory Pool
To store immutable object
-- Runtime Constant Pool
Runtime constant pool is per-class runtime representation of constant pool in a class. It contains class runtime constants and static methods. Runtime constant pool is the part of method area.
VM Switch VM Switch Description
-Xms For setting the initial heap size when JVM starts
-Xmx For setting the maximum heap size.
-Xmn For setting the size of the Young Generation, rest of the space goes for Old Generation.
-XX:PermGen For setting the initial size of the Permanent Generation memory
-XX:MaxPermGen For setting the maximum size of Perm Gen
-XX:SurvivorRatio For providing ratio of Eden space and Survivor Space, for example if Young Generation size is 10m and VM switch is -XX:SurvivorRatio=2 then 5m will be reserved for Eden Space and 2.5m each for both the Survivor spaces. The default value is 8.
-XX:NewRatio For providing ratio of old/new generation sizes. The default value is 2.
Resource Link :
http://howtodoinjava.com/core-java/garbage-collection/jvm-memory-model-structure-and-components/
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html
http://www.journaldev.com/2856/java-jvm-memory-model-and-garbage-collection-monitoring-tuning
- Heap area
Objects and array stored
Created when JVM started define fix size or vary between min and max size –Xms -Xmx
Yong Generation
Eden Memory
Survivor Memory
Most of the newly created objects are located in the Eden memory space.
When Eden space is filled with objects, Minor GC is performed and all the survivor objects are moved to one of the survivor spaces.
Old Generation
after many rounds of minor GC object is moved to the Old generation space.
-- Perm Gem :
Permanent Generation or “Perm Gen” contains the application metadata required by the JVM to describe the classes and methods used in the application. Note that Perm Gen is not part of Java Heap memory.
- Method area and runtime constant pool
field, method data, code, constructor ,
created on JVM started its part of Heap Memory
The method area may be of a fixed size or may be expanded as required by the computation and may be contracted if a larger method area becomes unnecessary
- JVM stack
Each of the JVM threads has a private stack created at the same time as that of the thread. The stack stores frames. A frame is used to store data and partial results and to perform dynamic linking, return values for methods, and dispatch exceptions.
If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError.
f Java Virtual Machine stacks can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, or if insufficient memory can be made available to create the initial Java Virtual Machine stack for a new thread, the Java Virtual Machine throws an OutOfMemoryError.
- Native method stacks
Native method stacks is called C stacks; it support native methods (methods written in a language other than the Java programming language), typically allocated per each thread when each thread is created. Java Virtual Machine implementations that cannot load native methods and that do not themselves rely on conventional stacks need not supply native method stacks.
The size of native method stacks can be either fixed or dynamic.
- PC registers
-- Memory Pool
To store immutable object
-- Runtime Constant Pool
Runtime constant pool is per-class runtime representation of constant pool in a class. It contains class runtime constants and static methods. Runtime constant pool is the part of method area.
VM Switch VM Switch Description
-Xms For setting the initial heap size when JVM starts
-Xmx For setting the maximum heap size.
-Xmn For setting the size of the Young Generation, rest of the space goes for Old Generation.
-XX:PermGen For setting the initial size of the Permanent Generation memory
-XX:MaxPermGen For setting the maximum size of Perm Gen
-XX:SurvivorRatio For providing ratio of Eden space and Survivor Space, for example if Young Generation size is 10m and VM switch is -XX:SurvivorRatio=2 then 5m will be reserved for Eden Space and 2.5m each for both the Survivor spaces. The default value is 8.
-XX:NewRatio For providing ratio of old/new generation sizes. The default value is 2.
Resource Link :
http://howtodoinjava.com/core-java/garbage-collection/jvm-memory-model-structure-and-components/
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html
http://www.journaldev.com/2856/java-jvm-memory-model-and-garbage-collection-monitoring-tuning
No comments:
Post a Comment