OutOfMemoryError: metaspace with ByteBuddy (HHH-14694)

Hello,
last week, we upgraded a legacy web application to hibernate-core 5.5.7.Final and were affected by an OOM error which manifests exactly as described in HHH-14694: when an entity manager factory is closed, its ByteBuddy-synthesized proxy classes with names like com.example.Account$HibernateProxy$T803qhHQ remain in memory and exhaust the metaspace after some time.

Trying out different things with the test case which is attached to that Jira issue, using Javassist instead of ByteBuddy (-Dhibernate.bytecode.provider=javassist) solves the problem for us, but as Javassist is deprecated, I would like to ask if there is any other known workaround or whether the bug will be fixed some time soon.

Thank you

Kambiz Darabi

m-creations gmbh
Acker 2
55116 Mainz
Germany

W: http://www.m-creations.com

I’m not aware of anyone actively working on this. Why do you create and close multiple entity manager factories though? This is not really a use case that we invest a lot of time into, although I agree that we should fix this issue eventually.

Hello,

thank you for your quick reponse! As this is (legacy) code which we didn’t touch, I need to investigate a bit further on why multiple factories are instantiated.

Kambiz

We have the same problem in our professional context: a process runs out of meta space because of thousands of hibernate proxies.

The use-case is a data base export: we export application meta data into a SQL database. To this end, the entitymanagerfactory is instantiated temporarily.

A systematic solution would be highly appreciated, especially since support for javaassist has been marked as deprecated.