mirror of
https://github.com/livekit/livekit.git
synced 2026-04-11 00:35:39 +00:00
When a subscriber disconnects, observer closures registered on the publisher's TrackChangedNotifier and TrackRemovedNotifier were never removed. These closures capture the SubscriptionManager, which holds the ParticipantImpl, preventing the entire participant object graph (PCTransport, SDPs, RTP stats, DownTracks) from being garbage collected. In rooms with many participants that disconnect and reconnect frequently, this causes unbounded memory growth proportional to the number of disconnect events. The leaked memory is not recoverable while the room remains open. Clear notifiers in both handleSubscribedTrackClose (individual subscription teardown) and SubscriptionManager.Close (full participant teardown), matching the existing cleanup in handleSourceTrackRemoved. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>