Good morning
I hava a problem with SessionFactory.
To create a SessionFactory I use this code
public static SessionFactory getSessionFactory() {
if (sessionFactory == null) {
log.info("I'm creating a new SessionFactory Hibernate");
// loads configuration and mappings
Configuration configuration = new Configuration().configure();
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
// builds a session factory from the service registry
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
}
return sessionFactory;
}
When I run my app the log
log.info("I'm creating a new SessionFactory Hibernate");
is printed only one time as aspected.
The problem is that almost every day the JVM reboot because of Out Of Memory error.
I analyse the dump and in the Leaks section the first suspect is SessionFactory. This is the complete leak message
145 instances of “org.hibernate.internal.SessionFactoryImpl”, loaded by “org.apache.catalina.loader.ParallelWebappClassLoader @ 0x6b0073940”
occupy 3,723,001,840 (59.16%) bytes. These instances are referenced from one instance of “java.util.concurrent.ConcurrentHashMap$Node”,
loaded by “”
How is it possible that 145 instances of SessionFactoryImpl is created even if the creation log appears only one time?
How can I check who created them? There is some log that can I activate?
Thanks
Regards