Tweets about "XX:MaxPermSize"
Java Heap Space (JHS)
Java Heap Space(JHS) is a Memory Area (generally located at bottom of address space and move upwards) inside the Java Process which holds the JVM objects.
JHS is divided into 3 REGIONs or GENs for sake of GC
1) New/YoungGen : where all new objects are created
2) Old/TenuredGen : where objects are placed when the NewGen overflows
Native memory
3) MetaSpace : holds the JVM’s class{..} and method objects
: contains meta-data of the classes and the objects
i.e. pointers into the rest of the heap where the objects are allocated.
So, JHS = NewGen + OldGen
Metaspace is garbage collected during full GC (Full GC is cleaning the entire Heap – both YoungGen and TenuredGen.) in hotspot JVM.
GC of the dead classes and classloaders is triggered once the class metadata usage reaches the “MaxMetaspaceSize”.
Relationship between Java Classes and PermGen (klass = class metadata)
Java classes are stored in the Metaspace. (Presenting the PermGen, 2006)
Fig. Relationship between Java Classes and PermGen (Presenting the Permanent Generation, 2006)
JVM Option Categories
[1] Heap/Vrt Memory Options -> specified with -X_[n]m
-Xms
-Xmx
If Java app is large and lots of object are created, the size of HeapSpace can be configured by using JVM options -Xms and -Xmx. (How to increase size of Java Heap, 2011)
[2] Non-heap/ Native memory options -> specified with -XX:_=[n]m
-XX:MaxMetaspaceSize : Max Java Perm(anent)SpaceSize
( min/default metaspace- min is dynamically re-size depending of the application demand at runtime)
The TomCat Server runs OutOfMemory if there are too many JVM classes or huge number of Strings in the project OR due to some reference to an object or a class loaded by the application’s ClassLoader that has died after that.
Also, http://stackoverflow.com/q/2431040/432903
EXAMPLE I : -XX:MaxMetaspaceSize=512M (1/4th of 2GB)Conf (with 2G of RAM available) for tomcat server using eclipse IDE
OR Add directly the following line to {TOMCAT_DIR}/bin/catalina.sh
CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:MaxMetaspaceSize=512m"
The fact is that once Java Classes are loaded, they stay in memory even if no one cares anymore.
Use the following content to {TOMCAT_DIR}/bin/catalina.sh to enable +CMSClassUnloadingEnabled so that GC will Sweep PermGen, and remove classes which are no longer used.
CATALINA_OPTS="$CATALINA_OPTS -server
-Xms256m
-Xmx1024m
-XX:MaxMetaspaceSize=512m
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled"
Have a look at hotspot/src/share/vm/runtime/globals.hpp of JDK for these variables.
And other important thing here is CMS in +CMSClassUnloadingEnabled which stands for Concurrent,Mark,Sweep, which is an algorithm/method for GC that, in theory, affects the performance of the application less than the older methods. G1st (Garbage First) is it's new competitor.
EXAMPLE II : JVM Switches for netbeans
add the following content to $NETBEANS_HOME/etc/netbeans.conf
#command line switches:
netbeans_default_options =
"-J-Xmx1024M
–J-XX:MaxMetaspaceSize=512m
-J-XX:+UseConcMarkSweepGC
-J-XX:+CMSClassUnloadingEnabled
-J-XX:+CMSPermGenSweepingEnabled
-J-XX:CompileThreshold=1000"
EXAMPLE III : -XX:MaxPermSize Conf (with 2G of RAM available) For GWT Dev Mode
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M -XX:MaxMetaspaceSize=1024m"/>
OR with +UseConcMarkSweepGC
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M -XX:MaxMetaspaceSize=1024m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"/>
(For gwt better performance, before starting in hosted mode delete app-server/src/main/webapp/gwt-unitCache/*.*)
References
Presenting the Permanent Generation , 2006 (HIGHLY RECOMMENDED) https://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation
What is a PermGen leak?, http://plumbr.eu/blog/what-is-a-permgen-leak
10 points about Java Heap Space or Java Heap Memory,
http://javarevisited.blogspot.sg/2011/11/hotspot-jvm-options-java-examples.html
Java HotSpot VM Options,
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
Tuning Garbage Collection with the 1.4.2 Java[tm] Virtual Machine,
http://www.oracle.com/technetwork/java/gc1-4-2-135950.html#3.%20Sizing%20the%20Generations|outline
10 Examples of HotSpot JVM Options in Java, http://javarevisited.blogspot.sg/2011/11/hotspot-jvm-options-java-examples.html
Pick up performance with generational garbage collection, http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
Full GC becoming very frequent, http://stackoverflow.com/a/7917221/432903
http://www.maths.lse.ac.uk/Courses/MA407/gcsurvey.pdf
Java Heap Space (JHS)
Java Heap Space(JHS) is a Memory Area (generally located at bottom of address space and move upwards) inside the Java Process which holds the JVM objects.
JHS is divided into 3 REGIONs or GENs for sake of GC
1) New/YoungGen : where all new objects are created
2) Old/TenuredGen : where objects are placed when the NewGen overflows
Native memory
3) MetaSpace : holds the JVM’s class{..} and method objects
: contains meta-data of the classes and the objects
i.e. pointers into the rest of the heap where the objects are allocated.
So, JHS = NewGen + OldGen
Metaspace is garbage collected during full GC (Full GC is cleaning the entire Heap – both YoungGen and TenuredGen.) in hotspot JVM.
GC of the dead classes and classloaders is triggered once the class metadata usage reaches the “MaxMetaspaceSize”.
Relationship between Java Classes and PermGen (klass = class metadata)
Java classes are stored in the Metaspace. (Presenting the PermGen, 2006)
Fig. Relationship between Java Classes and PermGen (Presenting the Permanent Generation, 2006)
JVM Option Categories
[1] Heap/Vrt Memory Options -> specified with -X_[n]m
-Xms
- Initial JavaHeapSize (default for client JVM is 1/64th part of Physical memory upto 1G)
- Setting InitialHeapMemory equal to the MaxHeapMemory, will eliminate any need for the JVM to reallocate the Heap Memory, leaving more to be used by other memory-intensive processes. (Common Tomcat Memory Issues and How To Fix Them, mulesoft.com)
-Xmx
- Max JavaHeapSize (default for client JVM is 1/4th of physical memory for size upto 1G)
- Starting the JVM with a higher Max Heap Memory will decrease the frequency with which GC occurs, eliminating excessive GC thus JVM gets optimized. (Common Tomcat Memory Issues and How To Fix Them, mulesoft.com)
If Java app is large and lots of object are created, the size of HeapSpace can be configured by using JVM options -Xms and -Xmx. (How to increase size of Java Heap, 2011)
[2] Non-heap/ Native memory options -> specified with -XX:_=[n]m
-XX:MaxMetaspaceSize : Max Java Perm(anent)SpaceSize
( min/default metaspace- min is dynamically re-size depending of the application demand at runtime)
The TomCat Server runs OutOfMemory if there are too many JVM classes or huge number of Strings in the project OR due to some reference to an object or a class loaded by the application’s ClassLoader that has died after that.
Also, http://stackoverflow.com/q/2431040/432903
EXAMPLE I : -XX:MaxMetaspaceSize=512M (1/4th of 2GB)Conf (with 2G of RAM available) for tomcat server using eclipse IDE
OR Add directly the following line to {TOMCAT_DIR}/bin/catalina.sh
CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:MaxMetaspaceSize=512m"
The fact is that once Java Classes are loaded, they stay in memory even if no one cares anymore.
Use the following content to {TOMCAT_DIR}/bin/catalina.sh to enable +CMSClassUnloadingEnabled so that GC will Sweep PermGen, and remove classes which are no longer used.
CATALINA_OPTS="$CATALINA_OPTS -server
-Xms256m
-Xmx1024m
-XX:MaxMetaspaceSize=512m
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled"
Have a look at hotspot/src/share/vm/runtime/globals.hpp of JDK for these variables.
And other important thing here is CMS in +CMSClassUnloadingEnabled which stands for Concurrent,Mark,Sweep, which is an algorithm/method for GC that, in theory, affects the performance of the application less than the older methods. G1st (Garbage First) is it's new competitor.
EXAMPLE II : JVM Switches for netbeans
add the following content to $NETBEANS_HOME/etc/netbeans.conf
#command line switches:
netbeans_default_options =
"-J-Xmx1024M
–J-XX:MaxMetaspaceSize=512m
-J-XX:+UseConcMarkSweepGC
-J-XX:+CMSClassUnloadingEnabled
-J-XX:+CMSPermGenSweepingEnabled
-J-XX:CompileThreshold=1000"
EXAMPLE III : -XX:MaxPermSize Conf (with 2G of RAM available) For GWT Dev Mode
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M -XX:MaxMetaspaceSize=1024m"/>
OR with +UseConcMarkSweepGC
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M -XX:MaxMetaspaceSize=1024m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"/>
(For gwt better performance, before starting in hosted mode delete app-server/src/main/webapp/gwt-unitCache/*.*)
References
Presenting the Permanent Generation , 2006 (HIGHLY RECOMMENDED) https://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation
What is a PermGen leak?, http://plumbr.eu/blog/what-is-a-permgen-leak
10 points about Java Heap Space or Java Heap Memory,
http://javarevisited.blogspot.sg/2011/11/hotspot-jvm-options-java-examples.html
Java HotSpot VM Options,
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
Tuning Garbage Collection with the 1.4.2 Java[tm] Virtual Machine,
http://www.oracle.com/technetwork/java/gc1-4-2-135950.html#3.%20Sizing%20the%20Generations|outline
10 Examples of HotSpot JVM Options in Java, http://javarevisited.blogspot.sg/2011/11/hotspot-jvm-options-java-examples.html
Pick up performance with generational garbage collection, http://www.javaworld.com/javaworld/jw-01-2002/jw-0111-hotspotgc.html
Full GC becoming very frequent, http://stackoverflow.com/a/7917221/432903
http://www.maths.lse.ac.uk/Courses/MA407/gcsurvey.pdf
No comments:
Post a Comment