Reputation: 91
After the tomcat ran several months, I got unexpectetly the error below. We restarted the tomcat and the error do not appear now but may be will come again in the future. I saw that another users had simmilar exceptions, related with the garbage collection, but not related exactly with the NIO connector.
Does somebody has an idea why this happens and what should be the correct fix to avoid it.
Jan 15, 2016 7:46:47 AM org.apache.tomcat.util.net.NioEndpoint$SocketProcessor run
SEVERE:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Collections.synchronizedSet(Collections.java:1691)
at org.atmosphere.cpr.AtmosphereRequest$Builder.<init>(AtmosphereRequest.java:1146)
at org.atmosphere.cpr.AtmosphereRequest.wrap(AtmosphereRequest.java:1891)
at org.atmosphere.cpr.AtmosphereServlet.event(AtmosphereServlet.java:295)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilterEvent(ApplicationFilterChain.java:484)
at org.apache.catalina.core.ApplicationFilterChain.doFilterEvent(ApplicationFilterChain.java:377)
at org.apache.catalina.core.StandardWrapperValve.event(StandardWrapperValve.java:411)
at org.apache.catalina.core.StandardContextValve.event(StandardContextValve.java:146)
at org.apache.catalina.valves.ValveBase.event(ValveBase.java:224)
at org.apache.catalina.core.StandardHostValve.event(StandardHostValve.java:256)
at org.apache.catalina.valves.ValveBase.event(ValveBase.java:224)
at org.apache.catalina.valves.ValveBase.event(ValveBase.java:224)
at org.apache.catalina.core.StandardEngineValve.event(StandardEngineValve.java:138)
at org.apache.catalina.connector.CoyoteAdapter.event(CoyoteAdapter.java:210)
at org.apache.coyote.http11.Http11NioProcessor.event(Http11NioProcessor.java:124)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1690)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Upvotes: 9
Views: 30748
Reputation: 2309
If you are running Tomcat from the following (Windows):
catalina.bat start
Then, you should create a file setenv.bat
and add the following line:
set JAVA_OPTS="-Xms4096m -Xmx4096m"
If you are running Tomcat from the following (Linux):
catalina.sh start
Then, you will have to do a similar thing and create setenv.sh adding something like the following:
export JAVA_OPTS="-Xms4096m -Xmx4096m"
See also Increase Tomcat memory settings
If you are running Tomcat from a Windows Service that was installed using the Tomcat installer, go to the Windows command prompt and run something like this (this is for Tomcat 8 and can be found in something like C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin
):
Tomcat8w.exe
Under the Java
tab, you will see Initial memory pool
and Maximum memory pool
. Enter this into both fields:
4096
Click Apply
and OK
.
From Task Manager
, Services
Tab, Services
, Select Apache Tomcat
and press start
See also Configure Tomcat as a service (no catalina.bat) and https://plavc.wordpress.com/2012/02/08/tomcat-service-on-windows/
Upvotes: 10
Reputation: 17524
Either your server didn't have enough memory to manage some particularly memory-consuming task, or you have a memory leak.
-Xmx
and -Xms
VM arguments, see Java VM options .This topic shows a full example for Tomcat : Increase Tomcat memory settings
heap dump
, with jmap for instance.A heap dump file represents the current heap allocation of a java process.
jmap -dump:file=<file-name> <process-id>
Here, <file-name>
is the file you want to create, and <process-id>
is the id of the Tomcat process.
Some tools like Eclipse MAT , can open and analyze a heap dump file, tell you the number of objects by class, occupied memory by object types, memory leak suspects, and so on...
Upvotes: 6