Skip to content

Live reload classloader memory leak when using hibernate-envers with a custom revision entity #46102

Closed
@jin-harmoney

Description

@jin-harmoney

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.

Image

How to Reproduce?

Reproducer: https://github.com/jin-harmoney/quarkus-hibernate-envers-classloader-leak

  • Run quarkus dev
  • Attach your favorite profiler
  • Do a couple changes to trigger multiple live reloads and observe that classloaders are not garbage collected
  • Remove the class CustomRevisionEntity
  • Do a couple changes to trigger multiple live reloads and observe that classloaders are not garbage collected

Output of uname -a or ver

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 or gradlew --version)

Apache Maven 3.9.9

Additional information

No response

Metadata

Metadata

Assignees

Labels

area/hibernate-ormHibernate ORMkind/bug-thirdpartyBugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions