Tuesday, 3 January 2012

What is JVM Heap Size

This is a parameter which normally creates issues in our webserver configurations.

The Java virtual machine heap space is the memory region where the Java objects (both live and dead) resided. When the Java heap runs out of space, the Java Garbage Collector is invoked to deallocate unreferenced objects and free up more space for the program to continue its operation. The JVM cannot service user requests during garbage collections. Many customers have their JVM heap size set to a minimum heap size of 64MB and maximum size of 256MB. Setting the JVM heap size to a greater minimum value (preferably equal to the maximum value) avoids the performance hit incurred by dynamically growing the JVM and improves predictability; it also lessens the frequency of JVM garbage collection.

The Java options, including the JVM heap size, that are used by WebLogic Server are stored in your WebLogic domain's setEnv.cmd(.sh). If you need to adjust any of the java options, including changing the JVM heap size you must manually edit WebLogic's setEnv script. The following two parameters, -Xms and -Xmx, respectively control the JVM min and max heap size, -Xms defines the minimum heap and -Xmx defines the maximum heap size. For performance reasons, it is recommended that both, min and max are set to the same value.Adjust the heap size as follows:
1) Edit the setEnv.cmd/sh script:
-For WebLogic 8.1, it is located in /webserv/
-For WebLogic 9.2 and 10.3, it is located in /webserv//bin
2) You will see a JAVA_OPTIONS parameter in this format: JAVA_OPTIONS_Where is the OS Platform that the web server is on.
3) This "JAVA_OPTIONS_" parameter is where the min/max heap settings are defined. Edit this parameter and adjust the heap settings.For example, to change the min/max heap settings from 256mg to 1gb on a Linux platform, you would change the JAVA_OPTIONS_LINUX parameter from:
JAVA_OPTIONS_LINUX="-jrockit -XnoOpt -XXnoJITInline -Xms256m -Xmx256m -Dtoplink.xml.platform....
to
JAVA_OPTIONS_LINUX="-jrockit -XnoOpt -XXnoJITInline -Xms1024m -Xmx1024m -Dtoplink.xml.platform....

The heap setting that you need to use, depends on environmental factors such as: -Number of users accessing the PeopleSoft application -Session Timeout setting (additional heap memory is needed for higher timeout settings, since the session information is stored in the java heap) -Types of transactions that users are runningIn a production environment, Oracle recommend a minimum heap setting of 512mg. But you may need to set heap higher depending on above factors. If the WebLogic java process runs out of java heap, it will log an 'OutOfMemory' error to file PIA_weblogic.log (and users may receive 'Error 500--Internal Server Errors').If you wish to analyze heap usage in your PeopleSoft environment, you may want to enable Verbose Garbage Collection as per the following document in metalink
Doc #759137.1: What is Verbose Garbage Collection (verbosegc) and How do I Enable it on WebLogic?

From metalink
PeopleTools 8.44-8.50, Weblogic uses a 32-bit Java version, which means that the java process is allowed only 4gb for java heap/native heap/executables . Therefore, if you set the java heap setting too high, the java process may not have enough memory remaining for native heap. So we recommend that you set heap no higher than 1.5GB, as this will allow extra memory for the native heap. If using JRockit, which uses more native memory than other Java brands, then the java heap setting may need to be even lower than 1.5GB.Also, note that when running WebLogic as a Window service, more memory overhead is needed for the service. Therefore you may need to make some adjustments to the heap size, when running as a Windows service.

Starting with PeopleTools 8.51, Weblogic uses a 64-bit Java version. So you can set your heap considerably higher as long as you have enough memory available on the web server. Note that if you use a larger heap setting (eg 4GB), then garbage collection may take longer. When garbage collection occurs, the "world stops", so there will be a momentary pause in processing transactions. So if you find that your environment requires a large java heap, then you may want to consider adding additional PIA's to your environment. For example, instead of having one WebLogic PIA with 8gb of heap, you could have two WebLogic PIA's, each with 4gb heap.

3 comments: