I'm using Spring Boot 1.2.5 with Java 1.8.0_51 and once the application is up and running, the metaspace keeps growing at a 10MB per hour rate aprox. Seems like a classloading leak or something, I just can not figure out what is causing it.
The application is running using Jetty instead of Tomcat.
I have a Reactor event loop running and a couple of scheduled processes. However these keeps happening when I turn them down.
These are some of the libraries I'm using:
spring-boot-starter-actuator
spring-boot-starter-aop
spring-boot-starter-data-jpa
spring-boot-starter-data-rest
spring-boot-starter-security
reactor-spring-context
hibernate-ehcache
One of the most common memory-related failures that occur in a Jetty web service (follow the Exceeding the maximum number of native threads problem and Exceeding the capacity of the heap issue) is exceeding the capacity of the permgen (where classes are allocated, transformed into MetaSpace in JDK 1.8 ).
Exceeding the Capacity of PermGen Space
Reasons:
- The applications installed on Jetty generate classes dynamically and PermGen/Metaspace space should be increased.
- A library or a piece of application code is dynamically creating an unbounded number of classes that are not eligible for garbage collection.
Example:
MessagePack generates template classes for each instance of MessagePack where those instances cache templates per instance. If the application creates too many instances of MessagePack, it’s likely that too many classes will be generated, which will eventually lead to a memory failure.
Diagnose:
The most effective way to diagnose issues related to memory on the Jetty web service is to connect to it via JMX and monitor it using jconsole. By default JMX is not enabled on Jetty but Spring Boot provides monitoring and management over JMX out of the box.
I'm only guessing but in the case of your application the reason of a problem could be the way you are using ehcache.