springwolf-core icon indicating copy to clipboard operation
springwolf-core copied to clipboard

Memory leak Springwolf, Kafka and Protobuf

Open amra opened this issue 4 months ago • 2 comments

Describe the bug In my spring boot application I use kafka and springwolf. After changing message serialization from json to protobuf the app consumes all memory assigned to java process.

After the analysis the cause is springwolf library. Using springwolf.enabled: false confirms the issue.

The memory consumption is significant. The app normally consumes up to 600MB (200MB after GC). But now it's 4.5GB (everything assigned to java process) within 1-2 minutes. The app consumes 95-100% of CPU time.

Dependencies and versions used

  • [x] springwolf-kafka version 1.15.0
  • [x] springwolf-ui version 1.15.0

Code example Configuration

springwolf:
    docket:
        base-package: com.company.msd
        info:
            title: ${spring.application.name}
            version: 1.0.0
        servers.kafka-server:
            protocol: kafka
            host: ${kafka.bootstrap.servers:localhost:29092}
    plugin:
        kafka:
            publishing:
                enabled: true

Stack trace and error logs All data are created after ~1minute of starting the app. Attached histogram is created using jcmd $PID GC.class_histogram, thread dumps using kill -3 $PID. develop-class-histogram.txt is created on branch without google protobuf and it's attached for comparison purpose.

protobuf-class-histogram12.txt threaddump-1.txt threaddump-2.txt threaddump-3.txt develop-class-histogram.txt

amra avatar Aug 28 '25 10:08 amra

Welcome to Springwolf. Thanks a lot for reporting your first issue. Please check out our contributors guide and feel free to join us on discord.

github-actions[bot] avatar Aug 28 '25 10:08 github-actions[bot]

Thanks you @amra for reporting this and attaching the thread dumps.

The thread dumps show high usage while generating the examples. We expect it to be related to the structure of your DTOs, as our simple kafka-example ExamplePayloadProtobufDto seems to work fine. Can you share those, especially when they have a cyclic structure?

timonback avatar Aug 29 '25 14:08 timonback