-
Notifications
You must be signed in to change notification settings - Fork 389
Description
Describe the bug
We're building an application on Quarkus and see increasing metaspace memory usage on every live reload. This is caused by the application classloader that is not garbage collected on live-reload.
This seems to be caused by the static ObjectMapper in ObjectMapperWrapper. The ObjectMapper is not loaded by the application classloader, but it does contain references to classes of our application (custom deserializers etc). Hence, it blocks the garbage collection of the application classloader.
To Reproduce
Let me know if I need to provide a reproducer (minimal Quarkus project). Since it's a live-reload issue, I don't think it's possible to add a test for this scenario.
Expected behavior
An elegant solution would be to able to clear all caches used by the ObjectMapper. I raised that question here: FasterXML/jackson-databind#4953.
An alternative solution would be to be able to set the ObjectMapper INSTANCE to null, so it can be garbage collected.
Similar to hibernate-envers, a disintegrate method could be introduced that:
- Removes any references to
ObjectMappers - Calls
objectMapper.clear()when such a method would be made available in jackson.
Additional context
I described a similar case for hibernate-envers quarkusio/quarkus#46102.
I'm happy to contribute with a PR!