I am running Tomcat application (which consists of Hibernate + EhCache). It is typical ORM webapp that shouldn't create lots of classes. However, Native Memory Tracking says "Nay".
During last 24 hours my webapp create on average ~1 new class per hour in Metaspace, with peak 11 classes per hour and peak 4 hours without creating classes.
So, I started with 7449 classes, after 24 hours I have 7481 classes. After inducing full GC, the number of classes can decrease by 0-2, but overall remains the same.
So
If classes are loaded lazily, how can I estimate the total number of classes to be created in native memory?
- I know Hibernate creates proxy classes. Is there a way to predict these proxy class count?
- How to force JVM to load all classes eagerly?
How can I log which new classes where loaded into Metaspace?
My configuration:
Server version: Apache Tomcat/8.0.28
OS Name: Linux
OS Version: 3.14.34-27.48.amzn1.x86_64
Architecture: amd64
JVM Version: 1.8.0_71-b15
JVM Vendor: Oracle Corporation
JVM flags: -Xms512m -Xmx2G -XX:+UseG1GC -XX:NativeMemoryTracking=summary -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMTStatistics
Hibernate 4.3.1