Skip to content
Advertisement

Why are there so many SessionFactoryImpl objects in the dump?

I have ~15,000 identical SessionFactoryImpl objects in my dump:

enter image description here

One of the objects with incoming references:

enter image description here

One of the objects with outbound references:

enter image description here

I don’t have the following parameters configured and they are set by default accordingly:

hibernate.query.plan_cache_max_size
hibernate.query.plan_parameter_metadata_max_size

Questions:

  1. Why are there so many SessionFactoryImpl objects and why aren’t they deleted?
  2. Are they created incorrectly somewhere in the code, or is it due to unspecified caching parameters?
  3. If so, what parameters should I set for caching?
  4. Should I set any other settings?
  5. If these objects are created in code, how can I find the class that creates these objects in Jprofiler?

Versions:

  • Hibernate 5.4.3.Final
  • Spring 5.1.6.RELEASE

Advertisement

Answer

The problem was in the incorrectly implemented method of logging to the database. When a certain task was completed, factories for logging were always created, which had a reference to the SessionFactoryImpl. And there were many such tasks, and each time these factories were created. We were able to find this place in the code and fix it so that the log factory was created once when the application was launched.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement