When I upload a big file through java application running on Websphere Application Server , I got OutOfMemoryError , as given below
JVMDUMP013I Processed Dump Event "uncaught", detail "java/lang/OutOfMemoryError".
Also memory leak is a common memory problem that also leads to OutOfMemory error. In Java , memory leaks can not happen as it has automatic Garbage Collection (GC). GC removes unused objects that are not referenced anymore. But if an object is not used, but is still referenced, GC does not remove it, which leads to memory leaks in JVM .
Due to the above memory leak or large objects error , the performance of the application server may decline or WAS may be crashed with OutOfMemory error. . Please check the error message java.lang.OutOfMemoryError” in the WAS log file ( i.e. native_stderr.log)
One of Solution to the above error :
When I increase the JVM Heap Size , the problem got solved . Now let us see , how to increase JVM Heap Size in Websphere Application Server
You can solve the problem in two ways
i) Using the IBM console
ii) By changing the server.index file directly
i). To tune the JVM Max Heap size using the IBM console
1. Open the WebSphere Application Server administrative console, http://hostname:port/ibm/console, and log in.
2. Expand Servers -> Application servers -> server1 -> Java and Process Management -> Process Definition -> Java Virtual Machine.
3. Change the Max Heap Size to a larger value.

4. Click Apply and click Save .
Restart WebSphere Application Server.
ii). By changing the server.xml file directly
Open the server.xml file located in the following directory
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/YourSrverNode01Cell/nodes/YourServerNode01/servers/server1
You may get the following lines related to JVM entries ...
<processDefinitions xmi:type="processexec:JavaProcessDef" xmi:id="JavaProcessDef_1268723379271" workingDirectory="${USER_INSTALL_ROOT}" executableTargetKind="JAVA_CLASS" executableTarget="com.ibm.ws.runtime.WsServer" >
<execution xmi:id="ProcessExecution_1268723379271" processPriority="20" runAsUser="" runAsGroup=""/> <ioRedirect xmi:id="OutputRedirect_1268723379271" stdoutFilename="${SERVER_LOG_ROOT}/native_stdout.log" stderrFilename="${SERVER_LOG_ROOT}/native_stderr.log"/ >
<monitoringPolicy xmi:id="MonitoringPolicy_1268723379271" maximumStartupAttempts="3" pingInterval="60" pingTimeout="300" autoRestart="true" nodeRestartState="STOPPED"/ >
<jvmEntries xmi:id="JavaVirtualMachine_1268723379271" verboseModeClass="false" verboseModeGarbageCollection="false" verboseModeJNI="false" initialHeapSize="250" maximumHeapSize="512" runHProf="false" debugMode="false" debugArgs="-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777" disableJIT="false"/ >
</processDefinitions >
Change the initialHeapSize to new larger value (i.e. 512 or 1024) and maximumHeapSize to new larger value (i.e. 2048) . If there is no parameters , you can add the two parameters (initialHeapSize="512" maximumHeapSize="2048") with value after verboseModeJNI="false" . Now save the server.xml file
Note : Changing the Max Heap Size to very larger value that is more than half of the total RAM , may result the following error when we start the WAS ,
VMJ9GC028E Option too large: '-Xmx4096m'
JVMJ9VM015W Initialization error for library j9gc23(2): Failed to initialize, parsing command line
Could not create the Java virtual machine.
Then you have to reduce the max heap size value using the IInd method ..(i.e. change server.xml file directly)
Tuning the max heap size
Setting the JVM heap size directly relates to the number of server instances need to be started on a specific node and the total RAM available on that machine. The total value of all server JVM heap sizes on a specific node must be less than half of the total RAM of that computer. To determine the max heap size , you can use the following equation
max_heap_size = Total_RAM / 2 / no_of_servers_instance
For example, to support two servers instance on a machine with 4 GB of RAM:
max_heap_size = 4 GB / 2 / 2
=2 GB / 2 = 1 GB
The maximum heap size is 1 GB for each server instance.
Default maximum heap size is 250 MB
Increasing the minimum heap size & maximum heap size can improve the start-up of application server. The number of garbage collection (GC) occurrences are reduced and a 10% gain in performance is realized.
How to determine Max Heap Size is too large or too small for your application.? If GC takes a so long time to clean up objects with large heap, you can reduce the maximum heap size. If GC frequency is too high, the heap may be too small for the application and GC needs to run frequently, so you may increase the maximum heap size.
JVMDUMP013I Processed Dump Event "uncaught", detail "java/lang/OutOfMemoryError".
Also memory leak is a common memory problem that also leads to OutOfMemory error. In Java , memory leaks can not happen as it has automatic Garbage Collection (GC). GC removes unused objects that are not referenced anymore. But if an object is not used, but is still referenced, GC does not remove it, which leads to memory leaks in JVM .
Due to the above memory leak or large objects error , the performance of the application server may decline or WAS may be crashed with OutOfMemory error. . Please check the error message java.lang.OutOfMemoryError” in the WAS log file ( i.e. native_stderr.log)
One of Solution to the above error :
When I increase the JVM Heap Size , the problem got solved . Now let us see , how to increase JVM Heap Size in Websphere Application Server
You can solve the problem in two ways
i) Using the IBM console
ii) By changing the server.index file directly
i). To tune the JVM Max Heap size using the IBM console
1. Open the WebSphere Application Server administrative console, http://hostname:port/ibm/console, and log in.
2. Expand Servers -> Application servers -> server1 -> Java and Process Management -> Process Definition -> Java Virtual Machine.
4. Click Apply and click Save .
Restart WebSphere Application Server.
ii). By changing the server.xml file directly
Open the server.xml file located in the following directory
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/YourSrverNode01Cell/nodes/YourServerNode01/servers/server1
You may get the following lines related to JVM entries ...
<processDefinitions xmi:type="processexec:JavaProcessDef" xmi:id="JavaProcessDef_1268723379271" workingDirectory="${USER_INSTALL_ROOT}" executableTargetKind="JAVA_CLASS" executableTarget="com.ibm.ws.runtime.WsServer" >
<execution xmi:id="ProcessExecution_1268723379271" processPriority="20" runAsUser="" runAsGroup=""/> <ioRedirect xmi:id="OutputRedirect_1268723379271" stdoutFilename="${SERVER_LOG_ROOT}/native_stdout.log" stderrFilename="${SERVER_LOG_ROOT}/native_stderr.log"/ >
<monitoringPolicy xmi:id="MonitoringPolicy_1268723379271" maximumStartupAttempts="3" pingInterval="60" pingTimeout="300" autoRestart="true" nodeRestartState="STOPPED"/ >
<jvmEntries xmi:id="JavaVirtualMachine_1268723379271" verboseModeClass="false" verboseModeGarbageCollection="false" verboseModeJNI="false" initialHeapSize="250" maximumHeapSize="512" runHProf="false" debugMode="false" debugArgs="-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777" disableJIT="false"/ >
</processDefinitions >
Change the initialHeapSize to new larger value (i.e. 512 or 1024) and maximumHeapSize to new larger value (i.e. 2048) . If there is no parameters , you can add the two parameters (initialHeapSize="512" maximumHeapSize="2048") with value after verboseModeJNI="false" . Now save the server.xml file
Note : Changing the Max Heap Size to very larger value that is more than half of the total RAM , may result the following error when we start the WAS ,
VMJ9GC028E Option too large: '-Xmx4096m'
JVMJ9VM015W Initialization error for library j9gc23(2): Failed to initialize, parsing command line
Could not create the Java virtual machine.
Then you have to reduce the max heap size value using the IInd method ..(i.e. change server.xml file directly)
Tuning the max heap size
Setting the JVM heap size directly relates to the number of server instances need to be started on a specific node and the total RAM available on that machine. The total value of all server JVM heap sizes on a specific node must be less than half of the total RAM of that computer. To determine the max heap size , you can use the following equation
max_heap_size = Total_RAM / 2 / no_of_servers_instance
For example, to support two servers instance on a machine with 4 GB of RAM:
max_heap_size = 4 GB / 2 / 2
=2 GB / 2 = 1 GB
The maximum heap size is 1 GB for each server instance.
Default maximum heap size is 250 MB
Increasing the minimum heap size & maximum heap size can improve the start-up of application server. The number of garbage collection (GC) occurrences are reduced and a 10% gain in performance is realized.
How to determine Max Heap Size is too large or too small for your application.? If GC takes a so long time to clean up objects with large heap, you can reduce the maximum heap size. If GC frequency is too high, the heap may be too small for the application and GC needs to run frequently, so you may increase the maximum heap size.
No comments:
Post a Comment