Open
Conversation
This commit fixes several critical memory leaks in the gzip compression middleware that could lead to significant memory accumulation under specific usage patterns. Changes: 1. Fixed WebSocket/Hijack resource leak (compress.go:213-219) - Close gzip writer before hijacking connection - Prevents ~32KB leak per WebSocket connection - Critical for long-lived WebSocket connections 2. Fixed Flush() buffer accumulation (compress.go:200-204) - Clear buffer after successful write during Flush() - Prevents unbounded memory growth in SSE scenarios - Important for Server-Sent Events and streaming responses 3. Improved pool management (compress.go:138-149) - Check writer state before returning to pool - Prevent corrupted writers from being reused - Eliminates potential data corruption issues Impact: - WebSocket connections: no longer leak gzip writers (~32KB each) - SSE/streaming: prevents linear buffer growth - Pool safety: eliminates race conditions from reused writers Fixes potential memory leaks affecting: - WebSocket applications using compression middleware - Server-Sent Events endpoints - Long-lived streaming connections - High-concurrency scenarios
Contributor
|
please provide proper description of the problem. it takes a little to much effort to understand the real-world situation, and you already have LLM created bullet list here so it should not be a problem. p.s. tests/poc would be also helpful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit fixes several critical memory leaks in the gzip compression middleware that could lead to significant memory accumulation under specific usage patterns.
Changes:
Fixed WebSocket/Hijack resource leak (compress.go:213-219)
Fixed Flush() buffer accumulation (compress.go:200-204)
Improved pool management (compress.go:138-149)
Impact:
Fixes potential memory leaks affecting: