-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
TypeFactory cache prevents garbage collection of custom ClassLoader #489
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
Comments
Ok I will need to think about this one. I can see why this is problematic for your case. At minimum, method to clear cache would certainly be doable. |
As per check-in, added |
I think that the use of weak/soft references is problematic (for performance, code complexity), so addition of But one thing that could be done, if this is still an issue, would be to consider possibility of plugging in different |
Closing for now; may be re-filed if there are good improvement ideas. |
Hi,
I use JSON (de)serialization via an ObjectMapper. Our application has a plug-in infrastructure where each plugin will get its own ClassLoader. The problem now is that the cache in the com.fasterxml.jackson.databind.type.TypeFactory keeps references to classes of our plug-in which prevents the garbage collection of those ClassLoaders on a plug-in shutdown. Of course, its not the cache itself but the keys / values used
(ClassKey._class / JavaType._class).
Please find a strong simplified working example below:
Currently we use jackson-databind 2.2.2, but the issue also arises in 2.4.
A cool fix would be to use weak references but I guess this will have too much impact. Another simple solution would be to offer a TypeFactory.clearCache() method or something similar.
Thanks & regards,
Urs
The text was updated successfully, but these errors were encountered: