1

I'm using tomcat 8 with jdk 8. Metaspace is set to 1GB which I feel is very enough,I'm getting OutOfMemoryError exception. I have tryed checking the class (SSLEngineImpl.java:1796)to get what is causing this but it seems that the line in error is not refering to any load of class. Can any one help on this please?

[http-nio-8202-exec-2] org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun 
 java.lang.OutOfMemoryError: Metaspace
    at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1796)
    at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
    at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
    at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
    at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
    at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap(SecureNioChannel.java:350)
    at org.apache.tomcat.util.net.SecureNioChannel.handshake(SecureNioChannel.java:208)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1496)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Zizou
  • 831
  • 1
  • 10
  • 19

1 Answers1

1

From the Docs

Exception in thread thread_name : java.lang.OutOfMemoryError: Metaspace Cause: Java class metadata (virtual machine internal representation of Java class) is allocated in native memory (here called metaspace). When the class metadata metaspace is exhausted, an exception with MetaSpace a detail of " " java.lang.OutOfMemoryError is thrown. The amount of metaspace available for class metadata is MaxMetaSpaceSize limited by the parameters specified on the command line . An exception is thrown with details MaxMetaSpaceSize if the amount of native memory required for class metadata is exceeded .MetaSpacejava.lang.OutOfMemoryError Action: If it MaxMetaSpaceSize is set on the command line, increase its value. MetaSpaceIs allocated from the same address space as the Java heap. Reducing the size of the Java heap MetaSpace increases the space available to it. This tradeoff only holds when there is extra free space in the Java heap. Following "Out of swap space" please refer to the "treatment" of the detail message.

In Java 8 and onwards, we can set the initial and maximum size of Metaspace using the following commands:

-XX:MetaspaceSize=N  - sets the initial (and minimum size) of the Metaspace.

-XX:MaxMetaspaceSize=N  - sets the maximum size of the Metaspace.
Yugansh
  • 365
  • 3
  • 9
  • Thanks @Yugansh for your answer. I have seen the documentation and I'm already setting meta space size to 1 GB using XX:MaxMetaspaceSize, but my question was about was classes tomcat try to do load to get that exception because i believe that 1GB should be very enough – Zizou May 14 '19 at 13:01