I have ~15,000 identical SessionFactoryImpl objects in my dump:
One of the objects with incoming references:
One of the objects with outbound references:
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:
- Why are there so many SessionFactoryImpl objects and why aren’t they deleted?
- Are they created incorrectly somewhere in the code, or is it due to unspecified caching parameters?
- If so, what parameters should I set for caching?
- Should I set any other settings?
- 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.