fix: release response memory immediately to prevent OOM#2118
Merged
Conversation
There was a problem hiding this comment.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on December 23
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
NadavLevi
reviewed
Nov 26, 2025
NadavLevi
reviewed
Nov 26, 2025
NadavLevi
reviewed
Nov 26, 2025
NadavLevi
reviewed
Nov 26, 2025
6df5122 to
b9e2ae5
Compare
Release large JSON-RPC response memory immediately after consumption to prevent out-of-memory issues with large payloads. Changes: - Clear resp.Result after unmarshaling in BatchCallContext - Clear source rpcMessage.Result after conversion in ConvertJsonRPCMsg - Clear batch[].Result immediately after conversion in sendBatchMessage - Clear replyMsgs after successful marshaling - Clear rpcMessage and replyMsg after all references complete in SendNodeMsg All cleanup happens AFTER data consumption to ensure correctness while reducing memory pressure from large JSON payloads across all chain types.
b9e2ae5 to
78b9b73
Compare
Use specialized structs in CheckResponseError and CheckResponseErrorForJsonRpcBatch to avoid unmarshaling the Result field, preventing unnecessary memory allocation for large payloads during error checks.
NadavLevi
previously approved these changes
Nov 30, 2025
2a2ec90 to
d3e3beb
Compare
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.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changemainbranchReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Note
Reduce peak memory by clearing large JSON-RPC Result fields ASAP and unmarshalling only error fields; minor test timing tweaks.
CheckResponseErrorandCheckResponseErrorForJsonRpcBatchto avoid allocating largeresultpayloads (protocol/chainlib/chainproxy/rpcInterfaceMessages/jsonRPCMessage.go).Resultfields to enable GC:ConvertJsonRPCMsg, setrpcMsg.Result = nilpost-conversion.rpcclient/client.go: BatchCallContext), nilresp.Resultafter unmarshalling into targets.protocol/chainlib/jsonRPC.go):batch[idx].Result = nil; after marshaling replies, clearreplyMsgs[idx].Result.rpcMessage.Result = nil; after marshaling, clearreplyMsg.Result.10sto align with new processing timing (protocol/rpcsmartrouter/smartrouter_relay_state_machine_test.go).Written by Cursor Bugbot for commit d3e3beb. This will update automatically on new commits. Configure here.