Hell Everyone,
After a very long time I am working on Apache tomcat. While accessing application login page user facing some issue and getting some errors on the web browser. When I check the tomcat output logs I seen the below error.
SEVERE: Exception invoking periodic operation:
java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(HashMap.java:203)
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:178)
at org.apache.catalina.startup.HostConfig$DeployedApplication.<init>(HostConfig.java:1314)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:898)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)
In my case the allocated heap memory for running the application was too less as compared to my requirement. So I increase the Java Heap memory and it resolve my issue.
When you initiate the command to start the Apache tomcat instance it take the configuration from the file catalina.sh. If you want to increase the java heap space you need to manually edit this file. For increasing the java heap space increase the value of -Xmx parameter for the CATALINA_OPTS
E.g.
cd /usr/local/apache-tomcat-5.5.23/bin/
vi catalina.sh
JAVA_HOME=/usr/java
CATALINA_OPTS="-Xmx512m " [In my case previously it was -Xmx126m]
Save the Configuration changes and start restart the Apache tomcat service.
/usr/local/apache-tomcat-5.5.23/bin/shutdown.sh
/usr/local/apache-tomcat-5.5.23/bin/startup.sh
Note: Do not Increase the heap size blindly, it will not help you every time in case of the Out Of Memory Error. Make a habit to analyze the heap dump and try to find out the best suitable JVM arguments for your environment.
Best Guide for Garbage Collection
Best Guide for JVM tuning.
Hope this will help you. Kindly comment for your suggestion and quires.
"Effort only fully releases its reward after a person refuses to quit.”
Regards,
Akhilesh B. Humbe
After a very long time I am working on Apache tomcat. While accessing application login page user facing some issue and getting some errors on the web browser. When I check the tomcat output logs I seen the below error.
Log Location:
/usr/local/apache-tomcat-5.5.23/logs/catalina.outError:
Jan 14, 2016 10:40:36 AM org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor processChildrenSEVERE: Exception invoking periodic operation:
java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(HashMap.java:203)
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:178)
at org.apache.catalina.startup.HostConfig$DeployedApplication.<init>(HostConfig.java:1314)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:898)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)
Solution:
As you can see in error it's a java.lang.OutOfMemoryError: Java heap space means we don’t have enough heap memory available to write new objects of an application. There is not a single specific way to resolve this issue. There may be a different reasons of OutOfMemoryError. You can find out that by generating and analyzing heap dump.In my case the allocated heap memory for running the application was too less as compared to my requirement. So I increase the Java Heap memory and it resolve my issue.
How to increase the java heap space in Apache tomcat ?
When you initiate the command to start the Apache tomcat instance it take the configuration from the file catalina.sh. If you want to increase the java heap space you need to manually edit this file. For increasing the java heap space increase the value of -Xmx parameter for the CATALINA_OPTS
E.g.
cd /usr/local/apache-tomcat-5.5.23/bin/
vi catalina.sh
JAVA_HOME=/usr/java
CATALINA_OPTS="-Xmx512m " [In my case previously it was -Xmx126m]
Save the Configuration changes and start restart the Apache tomcat service.
/usr/local/apache-tomcat-5.5.23/bin/shutdown.sh
/usr/local/apache-tomcat-5.5.23/bin/startup.sh
Note: Do not Increase the heap size blindly, it will not help you every time in case of the Out Of Memory Error. Make a habit to analyze the heap dump and try to find out the best suitable JVM arguments for your environment.
Important:
How to take a Heap Dump.Best Guide for Garbage Collection
Best Guide for JVM tuning.
Hope this will help you. Kindly comment for your suggestion and quires.
"Effort only fully releases its reward after a person refuses to quit.”
Regards,
Akhilesh B. Humbe
No comments:
Post a Comment