butil::get_resource<Task> 疑似内存泄漏

Open
#2,910 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, linux

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.

Description

Describe the bug (描述bug)
使用BRPC框架的进程,长期运行(一个月),可以观察到内存持续上涨,如下图:

Image

追踪内存泄漏位置如下

Image

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

jemalloc 生成的内存分布占比:
memory.txt

Dominant language
C++
Stars
17.6k
Forks
4.2k
Avg merge
3d 17h
Merged PRs (30d)
72

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/brpc

All issues in apache/brpc

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.