Memory leak Springwolf, Kafka and Protobuf
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-kafkaversion1.15.0 - [x]
springwolf-uiversion1.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
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.
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?