Wednesday, April 22, 2015

JVM HotSpot memory

The JVM HotSpot memory is split between 3 memory spaces
  • The Java Heap.
  • The PermGen(perm) (permanent generation).
  • The Native Heap (C-Heap).

The Java Heap
  • Stores java objects.
  • Applicable for all JVM vendors.
  • It's usually  divided into generations:a-  The young generation (nursery):Stores short-lived objects that are created and immediately garbage collected.b-  The old generation (tenured):Objects that persist longer are moved to the old generation.
  • Start-up arguments and tuning:
    -Xmx (maximum Heap space) -Xms (minimum Heap size)
PermGen 
  • Keep information for the loaded classes (storing the Java Classes metadata)
  • String Pool which created by String.intern() method.
  • The PermGen space is only applicable to the HotSpot VM.
  • In Java 8, Oracle replaced the PermGen space for the HotSpot VM  with Metaspace.
  • Start-up arguments and tuning
    -XX:MaxPermSize (maximum size)    -XX:PermSize(minimum size)
Native Heap
  • Store third party native code objects.
  • Applicable for all JVM vendors.
Eating memory cases 
  • The more class loaders and classes that you load at runtime, higher demand on the HotSpot VM PermGen space and internal JIT related optimization objects.
  • The more applications you deploy to a single JVM, higher demand on native Heap.
  • Java threads require demand native memory.
  • Data caching not serialized to a disk or database will require extra memory from the OldGen space.
  • The java heap and native heap are in a race, the bigger your Java heap, smaller the native heap.  
Bytecode compilation uses native memory
Java applications run in the virtualized environment of the Java runtime, but the runtime itself is a native program written in a language (such as C) that consumes native resources, including native memory.
Every virtualized resource — including the Java heap and Java threads — must be stored in native memory, along with the data used by the virtual machine as it runs.
both the input (the bytecode) and the output (the executable code) from the JIT must also be stored in native memory.

Note 
 

  • JRockit and HotSpot are merging into one single JVM.
  • JDK 7 contains the first release of this converged JVM, which was one of the first steps was to start removing the PermGen concept in java 8.
  • The JDK 8 HotSpot JVM is now using native memory for the representation of class metadata and is called Metaspace; similar to the Oracle JRockit and IBM JVM's.
  • Java Metaspace space setting is to be unbounded (dynamic resize) by default.

Manage Memory for permanent generation space (permgen)
If your JDeveloper IDE  is slow, you can increase the memory by: 
Edit the "jdev.con" file located at path "YOUR_Oracle_Home\jdeveloper\jdev\bin​"
and add following line:
AddVMOptionHotspot  -XX:MaxPermSize=1024M

also you can show consumed memory and force for garbage collection by adding the following line:
AddVMOption -DMainWindow.MemoryMonitorOn=true

See the file after modifying:

  • Now you can see a new bar added at Jdeveloper IDE, the arrow points to link that do job for Garbage Collecting:
  • Now you are more far from the error: OutOfMemoryError PermGen Space Error.
  •  JDeveloper 12.1.3 in test can be configured to develop/compile against JDK 8, and introduces support for JDK 8 language features.

http://javaeesupportpatterns.blogspot.com/2011/08/java-heap-space-hotspot-vm.html
https://blogs.oracle.com/henrik/entry/java_7_questions_answers
http://architects.dzone.com/articles/5-tips-proper-java-heap-size
http://architects.dzone.com/articles/5-tips-proper-java-heap-size
http://www.ibm.com/developerworks/linux/library/j-nativememory-linux/index.html
https://sourcevirtues.wordpress.com/2013/01/14/java-heap-space-and-native-heap-problems/

http://waslleysouza.com.br/en/2014/04/increase-the-performance-of-jdeveloper-11g/
http://www.oracle.com/technetwork/developer-tools/jdev/documentation/121300-cert-2164864.html
http://java.dzone.com/articles/java-8-permgen-metaspace
http://en.wikipedia.org/wiki/Java_virtual_machine

No comments:

Post a Comment

java - fill distinct objects in ArrayList

If you have a list that contains some objects that it is considered as duplication when two or three fields of these objects are equal. How ...