butil::get_resource<Task> 疑似内存泄漏
- Dominant language
- C++
- Stars
- 17.6k
- Forks
- 4.1k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 69
Description
**Describe the bug (描述bug)**
使用BRPC框架的进程,长期运行(一个月),可以观察到内存持续上涨,如下图:

追踪内存泄漏位置如下

**To Reproduce (复现方法)**
单进程2k左右qps, 消息请求平均大小150KB
**Expected behavior (期望行为)**
期望内存不会持续上涨
**Versions (各种版本)**
OS:
Linux 5.15.0-125.006 #125~20.04.3 SMP Fri May 24 11:59:50 +08 2024 x86_64 x86_64 x86_64 GNU/Linux
Compiler:
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
brpc:
tag 1.10.0
jemalloc 生成的内存分布图:
[3_5.pdf](https://github.com/user-attachments/files/19084719/3_5.pdf)
jemalloc 生成的内存分布占比:
[memory.txt](https://github.com/user-attachments/files/19084786/memory.txt)
Contributor guide
Research direction
Start by inspecting butil::get_resource and reproduce the reported long-running workload of about 2,000 QPS with 150 KB requests on the stated Linux and brpc 1.10.0 environment. Use the provided jemalloc PDF and memory report to compare allocation growth; done means identifying and fixing the leak so memory no longer rises continuously under sustained load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100