In 4.3, if an exception occurs in the constructor of SessionFactoryImpl (e.g. schema validation fails), the SessionFactoryImpl object is kept in memory because it was added to the SessionFactoryRegistry. In our unit tests, this causes dozens of SessionFactories to be kept in the registry, until the heap is filled and OutOfMemoryErrors are thrown. This issue probably doesn't occur in Hibernate 5.0 because the code for adding the SessionFactoryImpl to the SessionFactoryRegistry was moved to the end of the SessionFactoryImpl constructor in
HHH-9655 Closed (this commit). I would like to propose backporting the 3 commits for
HHH-9655 Closed to the 4.3 branch. I can provide a pull request. |