spring-framework: Memory Leak with SseEmitter
Affects: webmvc 6.x
We have a new application that uses the SseEmitter to send events back to clients as they arrive in our system via a Kafka Consumer. Recently this application started crashing every few days with Heap OOM errors. After some analysis, it looks like what is happening is that the connection gets terminated, but the .onError handler is never called. As a result we treat the connection as still available and keep publishing events to it.
As part of the error, it looks like the underlying handler object is set to null. As a result, the message is queued in the earlySendAttempts LinkedHashSet. It continues to accumulate messages there and accumulate until a Heap OOM occurs.
Someone else reported the issue on Stackoverflow here.
This looks like it was introduced in the following commit from @bclozel.
Reproducibility is tough but I will continue to work for it
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (8 by maintainers)
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.