fix: prevent responseListeners memory leak in CoreMessenger#11901
Merged
Patrick-Erichsen merged 1 commit intomainfrom Mar 26, 2026
Merged
fix: prevent responseListeners memory leak in CoreMessenger#11901Patrick-Erichsen merged 1 commit intomainfrom
Patrick-Erichsen merged 1 commit intomainfrom
Conversation
Response listeners were only removed when data contained `"done": true`, but most message types (file events, autocomplete, nextEdit, etc.) return responses without a `done` field. This caused every fire-and-forget request to leak its callback lambda permanently in the map. Over a long session with heavy autocomplete and file navigation, this could accumulate hundreds of thousands of entries (40-100+ MB). Fix: invert the removal logic — remove the listener by default, and only keep it when `done == false` (i.e., a streaming response is still in progress). This preserves existing streaming behavior while ensuring all non-streaming responses are cleaned up immediately.
Contributor
Docs ReviewNo documentation updates needed for this PR. Reason: This is an internal bug fix that addresses a memory leak in the IntelliJ extension's
The fix improves memory management under the hood without changing how developers interact with Continue. |
Patrick-Erichsen
approved these changes
Mar 26, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
CoreMessenger.responseListenerswhere callback entries were never removed for non-streaming messagesdatacontained"done": true, but most message types (files/changed,files/opened, autocomplete,nextEdit/*, etc.) return responses without adonefield — leaking every callback permanentlydone == false(streaming still in progress). This is safe for all message types:done: false→done: true): listener kept during streaming, removed on completion — same as beforedonefield): listener removed immediately after callback — this is the fix{ _ -> }/{}): listener removed on first response — this is the fixRelated: #8085 (sidebar freezes), which identified memory pressure as a contributing factor
Test plan
responseListenersmap stays smallSummary by cubic
Fixes a memory leak in
CoreMessengerby removing response listeners by default and only keeping them during streaming (done == false). This preventsresponseListenersfrom growing unbounded during autocomplete and file events.done != false; keep only while streaming.done) and fire-and-forget calls now clean up after the first callback; streaming completion still removes ondone: true.Written for commit cf67e4d. Summary will update on new commits.