Skip to content

Expose DefaultSerializerProvider.flushCachedSerializers()? (or prevent Metaspace leaking without it) #1905

Closed
@mattsheppard

Description

@mattsheppard

If I provide Jackson's ObjectMapper new dynamically generated types on each request, I seem to get a process which grows in metaspace forever (or eventually throws an OutOfMemoryError error if I set a maximum bound on metaspace).

I created an example project to exhibit this at https://github.com/mattsheppard/JacksonDatabindMetaspaceLeak (it uses groovy to generate the dynamic classes because that's what the application I originally found the problem in used, but it doesn't appear to be groovy specific).

Note that this leaking occurs even if I call the TypeFactory's clear cache method which was discussed in #489.

I stumbled across ((DefaultSerializerProvider) mapper.getSerializerProvider()).flushCachedSerializers(); after exploring some heap dumps, and calling that every once-in-a-while seems to be sufficient to run more-or-less indefinitely.

If it's not possible to use weak references or allow for some sort of bounded cache to avoid the actual problem (#489 suggests you may be reluctant), would it at least be possible to expose the flush method on SerializerProvider to avoid the cast?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions