mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #4508] 内存慢慢泄露 #3559
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#3559
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?
Originally created by @ivanszl on GitHub (Oct 24, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/4508
Bug Description
在客户端经常性断开重连和每天产生很多动态客户端连接的时候,会出现内存慢慢增加的情况

整体如下图所示
查了下代码可能是在
pkg/nathole/nathole.go这个代码里
调整为如下是否可以避免
frpc Version
0.54.0
frps Version
0.54.0
System Architecture
linux/amd64
Configurations
bindPort = 8000
vhostHTTPPort = 8090
auth.method = "token"
auth.token = "****"
httpPlugins
name = "notify"
addr = "127.0.0.1:18081"
path = "/s/handler"
ops = ["NewProxy", "CloseProxy"]
Logs
No response
Steps to reproduce
...
Affected area
@fatedier commented on GitHub (Oct 24, 2024):
@ivanszl commented on GitHub (Oct 24, 2024):
这个是 30 天的frps 的 metrics 数据

代码块那里看到的是使用了内存池的模式,如果出现 decode 失败后,就会一直分配着不释放了
@fatedier commented on GitHub (Oct 24, 2024):
memory 有很多种,尽量用工具调试观测吧,我没有太多精力和你深入讨论这里面的技术细节。
@wuai1024 commented on GitHub (Oct 25, 2024):
我看了下我的 frps,目前监控数据如下(没有发现内存异常问题):


客户端很多 frpc 在使用

流量使用也算还可以吧

@ivanszl commented on GitHub (Oct 25, 2024):
我这边使用场景是客户端比较频繁的更换,频繁的上下线,更换了版本后还是会慢慢的增长
@wuai1024 commented on GitHub (Oct 25, 2024):
你应该是看错了指标, frps 的 metrics 数据中有多个内存指标。
你可以看看,参考下。
@ivanszl commented on GitHub (Oct 25, 2024):
日常连接使用如下图所示


程序占用内存如下图所示
@wuai1024 commented on GitHub (Oct 25, 2024):
用不了,格式不对,你发json 文件吧
@ivanszl commented on GitHub (Oct 25, 2024):
我是用这个 20370 ID 导入的,你试试看看
@wuai1024 commented on GitHub (Oct 25, 2024):
我也是用的这个,没有你那几个内存显示
@ivanszl commented on GitHub (Oct 25, 2024):
frps.json
@ivanszl commented on GitHub (Oct 25, 2024):
进程内存的两条线分别为:
process_resident_memory_bytes{instance=~"^($NODE)$"}
process_virtual_memory_bytes{instance=~"^($NODE)$"}
@wuai1024 commented on GitHub (Oct 25, 2024):
我的是这样的

@ivanszl commented on GitHub (Oct 25, 2024):
另一个稳定客户端连接内存也是很稳定,就只有在频繁端开,连接,实例名称是动态的会有问题
多谢,我这边再看看
@github-actions[bot] commented on GitHub (Nov 20, 2024):
Issues go stale after 21d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
@dishpzga commented on GitHub (May 16, 2025):
@fatedier @ivanszl 各位大神
我的frps服务器也出现了类似现象,4核CPU 32G内存的服务器 一般运行2周左右内存耗尽,frps版本0.46.1,下面是我连续几天观察发现的现象:
a. frps服务器:103.16、版本:0.46.1
b. 活跃连接数5000左右、frps占用内存1.5GB
a. 16:25 LISTEN状态4300 与之前持平,活跃TCP连接数基本维持在5000~6000之间,内存占用最高1.7GB
a. 09:30 活跃连接数降低到4800,内存占用1.8GB
b. 13:30 存在大量状态是 CLOSE_WAIT 的TCP连接 一段时间后释放、同时内存也从早上的1.8G增长到3.3GB、即使CLOSE_WAIT状态释放后内存也没有释放