-
Notifications
You must be signed in to change notification settings - Fork 374
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
Classloader not garbage collected due to reference from jackson ObjectMapper #764
Comments
PR raised on jackson-databind: FasterXML/jackson-databind#4954 to add support for If the PR would be accepted and since the static objectMapper INSTANCE can be accessed publicly, I guess there's no need for changes in this repo 🤔 Unless there's a way to call |
You can investigate the issue, and if you find a good solution to fix it, then send me a Pull Request, and I'll review it. |
@vladmihalcea my PR to jackson-databind is merged, so I can resolve this from within our application by calling To try to avoid the same issue for other users of hypersistence-utils, I investigated if there's a possibility to automatically clean up the objectMapper instance. Envers works with the Integrator interface, which provides a Hypersistence utils works with the TypeContributor interface, which does not provide a similar method. So at this moment, I don't think it's possible to do something similar as in Envers. Would it make sense to request an extension of the Another possible option would be to avoid that jackson modules from the application using hypersistence-utils are loaded in the static objectMapper in |
You can also add an Or, you can change the Instead of:
You change it to:
Try it and see if it works, and if it does, then we can change it. |
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
tonull
, so it can be garbage collected.Similar to hibernate-envers, a
disintegrate
method could be introduced that:ObjectMappers
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!
The text was updated successfully, but these errors were encountered: