-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live reload classloader memory leak when using hibernate-envers with a custom revision entity #46102
Comments
/cc @gsmet (hibernate-orm) |
Thanks for the reproducer, I'll have a look soon. |
I can confirm I can reproduce the issue. Now I need to understand what's going on. |
hibernate/hibernate-orm#9699 should fix it. If you want, you can try to apply it locally to Envers and report back with your project.
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-envers</artifactId>
<version>6.6.7-SNAPSHOT</version>
</dependency> |
@gsmet amazing, thank you! I can confirm the classloaders are garbage collected both in the reproducer and in our application! Small anecdote: we had issues with classloader memory leaks in Wildfly when redeploying our WAR. I tried to resolve it multiple times over the past 3 years, but I never figured it out. It was actually one of the reasons I pushed the migration to Quarkus :) It's a small fix, but to me (and my team), finally resolving this is a huge deal! So thank you again! |
Thanks for the confirmation and having a simple reproducer made a huge difference so thanks for taking the time to assemble one! I created a PR to get it backported to Hibernate ORM 6.6 so I hope it will land in Quarkus in a not too distant future. |
FWIW, I'm not very surprised. Quarkus dev mode allowed us to find many issues in various components not being very nice with reloading - and you would end up with the same problem in any app server when redeploying. |
So so true. Lot's of software out there is not created with reloading in mind |
Fix was merged on hibernate-orm 6.6.7 👍 |
@jin-harmoney the fix was released in 3.18.3. Thanks again for the nice reproducer! |
Describe the bug
I'm not sure if this issue belongs here or on the Hibernate issue tracker.
We're observing ever increasing metaspace memory consumption after each live reload.
The increasing metaspace memory consumption is because the classloaders are not garbage collected.
We're creating revision entries for all entities using Hibernate envers. In order to store some additional information on each revision, we use a custom revision entity. Removing the custom revision entity seems to allow garbage collection to occur, hence resolving the increasing memory consumption.
Expected behavior
Metaspace memory is stable over time, even when many live-reloads occur.
Classloaders are garbage collected even though a custom revision entity is used.
Actual behavior
When running
quarkus dev
, metaspace memory keeps increasing.This is almost not noticeable in the reproducer I provided, because there are only 3 classes loaded. In our application, each live reload adds about 50MB to metaspace, so eventually this leads to a large amount of memory that is not released.
The screenshot below (not super clear, sorry) shows the classloaders when I'm doing live-reloads. Sometimes, the classloaders are garbage collected, sometimes they are not. That corresponds to when I remove/restore the
CustomerRevisionEntity
class.How to Reproduce?
Reproducer: https://github.com/jin-harmoney/quarkus-hibernate-envers-classloader-leak
quarkus dev
CustomRevisionEntity
Output of
uname -a
orver
No response
Output of
java -version
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)
Quarkus version or git rev
3.18.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.9
Additional information
No response
The text was updated successfully, but these errors were encountered: