3

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
gvlasov
  • 18,638
  • 21
  • 74
  • 110
carlos_technogi
  • 198
  • 3
  • 6
  • you should trace classloading, class unloading and GC details to see whether any classloaders get GCed. you should also log/visualize metaspace size over time. It's possible that it's simply not yet hitting a high water mark that would require a collection. – the8472 Aug 11 '15 at 18:41
  • Thanks for your comment Suseika. I just traced the the class loading and I do not see anything strange. In the last hour I just loaded 10 classes, but the memory increased 10 MB. Currently I have the Metaspace max set to 200MB, for a Heap that runs without issues with 500MB and it eventually hit the 200MB and the app crashes. – carlos_technogi Aug 12 '15 at 02:56
  • You have the actuator in place, that is recording statistics and by default does al to of that in memory... You are also using caching (judging from the inclusion of `hibernate-ehcache` make sure your caches are cleared/updated properly. But all in all, slap a analyzer on it and analyze the behavior of your application. – M. Deinum Aug 12 '15 at 06:18

1 Answers1

0

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.

Karol Król
  • 3,320
  • 1
  • 34
  • 37