Skip to content
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

Add serializer-cache size limit to avoid Metaspace issues from caching Serializers #3311

Closed
mcolemanNOW opened this issue Oct 27, 2021 · 6 comments
Milestone

Comments

@mcolemanNOW
Copy link

mcolemanNOW commented Oct 27, 2021

I know this is a topic that has been discussed before (#489 & #1905), but it has been a few years so I wanted to open the discussion again.

I see that there are changes coming in 3.0 to limit the size of the serializer cache to 4000 (#1994). Are there any other plans to allow tuning this size, adding a 'super flush', or letting the consumer provide the cache implementation (ex. with weak references)?

Our app servers have a lot of DelegatingClassLoaders sticking around due to reflection methods being stored in the SerializerCache(like _accessorMethod in BeanPropertyWriter) and it would be great if we had more control over the caching strategy so metaspace doesn't grow unbounded.

@mcolemanNOW mcolemanNOW added the to-evaluate Issue that has been received but not yet evaluated label Oct 27, 2021
@cowtowncoder cowtowncoder changed the title Metaspace issues from caching Metaspace issues from caching Serializers Oct 27, 2021
@cowtowncoder
Copy link
Member

There is nothing specific, except that I think there were some concrete talks about exposing cache sizes through builders -- so at least you could limit maximum number -- and I think also ability to specify custom cache implementations. Latter would then allow more advanced handling if cache could determine how to clear references to obsolete instances.

@cjimenez1
Copy link

Is this consideration being made for the codehaus jackson implementation? There is a serializercache there as well, which will lead to pretty much the same impact.

https://github.com/codehaus/jackson/blob/master/src/mapper/java/org/codehaus/jackson/map/ser/impl/SerializerCache.java#L34

@yawkat
Copy link
Member

yawkat commented Oct 27, 2021

@cjimenez1 The codehaus implementation is Jackson 1.x and hasn't seen a release for 8 years. You should upgrade to Jackson 2.

@mcolemanNOW
Copy link
Author

The cache limit hasn't been backported to Jackson 2 either. Could that be considered as well?

@cowtowncoder
Copy link
Member

Yeah, Jackson 1.x has not been modified in literally years and I have no way to actually publish any of jars even if I did change the copy Github has. So issues it has will remain issues unless someone forks the build (or implements proper Maven build).

As to 2.x, sure, PRs welcome! I do not necessarily have time to make changes but can usually help others get PRs merged.

@cowtowncoder cowtowncoder added 2.14 and removed to-evaluate Issue that has been received but not yet evaluated labels Oct 27, 2021
@cowtowncoder cowtowncoder changed the title Metaspace issues from caching Serializers Metaspace issues from caching Serializers (add serializer-cache size limit in 2.x) Oct 27, 2021
@cowtowncoder
Copy link
Member

@pjfanning @ben-manes I think I'll try to do this (basically backport of #1994)

cowtowncoder added a commit that referenced this issue Jul 1, 2022
@cowtowncoder cowtowncoder changed the title Metaspace issues from caching Serializers (add serializer-cache size limit in 2.x) Add serializer-cache size limit to avoid Metaspace issues from caching Serializers Jul 1, 2022
@cowtowncoder cowtowncoder added this to the 2.14.0 milestone Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants