mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[PR #5203] [MERGED] fix: return buffers to pool on error paths to reduce GC pressure #5170
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#5170
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fatedier/frp/pull/5203
Author: @fatedier
Created: 3/6/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @fatedier
Base:
dev← Head:new📝 Commits (1)
521724bfix: return buffers to pool on error paths to reduce GC pressure📊 Changes
2 files changed (+3 additions, -0 deletions)
View changed files
📝
pkg/nathole/nathole.go(+2 -0)📝
pkg/proto/udp/udp.go(+1 -0)📄 Description
Summary
waitDetectMessageallocates a buffer viapool.GetBufeach loop iteration but never returns it on error paths (ReadFromUDPfailure andDecodeMessageIntofailure). Addedpool.PutBuf(buf)on both paths.writerFninForwarderallocates a buffer viapool.GetBufbut never returns it when the goroutine exits. Addeddefer pool.PutBuf(buf).These are
sync.Poolbuffer leaks — not permanent memory leaks, but they increase GC pressure and allocation rate under sustained load.Verification
json.Unmarshalcreates independent string copies, so returningbufto pool afterDecodeMessageIntois safe (no aliasing).NewUDPPacketcopiesbuf[:n]into a new slice, so returningbufvia defer inwriterFnis safe.Test plan
make buildpassesmake testpasses🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.