Repository navigation
fix(livekit): Memory leak during cancel publisher negotiation when rooms close - #1538
Merged
Merged
Conversation
Contributor
Changeset ✓This PR includes a changeset covering all affected packages:
|
alan-george-lk
force-pushed
the
alan/bugfix-session-inner-leak
branch
from
November 9, 2026 19:29
933fed4 to
51fef32
Compare
alan-george-lk
marked this pull request as ready for review
November 16, 2026 20:49
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
alan-george-lk
force-pushed
the
alan/bugfix-session-inner-leak
branch
from
November 16, 2026 20:55
0a0fbe3 to
793eb1f
Compare
ladvoc
approved these changes
Nov 18, 2026
ladvoc
left a comment
Contributor
There was a problem hiding this comment.
LGTM ✅. The complexity of this fix indicates we're due for a larger refactor, but given the current state of things, I'm not sure you can do much better.
xianshijing-lk
approved these changes
Nov 18, 2026
Collaborator
Author
|
Note: bypassed CI failure as confirmed it was unrelated to this change and was holding up a release. |
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.
Summary
This leak was detected during C++ regression test work catching memory leaks, see here: https://github.com/livekit/client-sdk-cpp/actions/runs/43513539718#summary-132669981633
It happens intermittently, but in troubleshooting with GPT this issue was identified.
Changes:
Root cause
Publisher negotiation ran in detached Tokio tasks that strongly retained
SessionInner. During rapid video publish, unpublish, and disconnect cycles, a task could remain waiting up to 10 seconds for an SDP answer and then retry after the room had closed. The retained session kept its peer connections, peer connection factory, media threads, and encoder resources alive.Validation
taskset -c 0,1: run 6 gained 8 threads and 64.44 MiBFixes BOT-586