使用ExecutionQueue时,压测时,内存从50mb上涨到800mb,停止压测后,内存不会降下来,如果继续压测,内存还会继续涨
- Dominant language
- C++
- Stars
- 17.6k
- Forks
- 4.1k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 69
Description
**Describe the bug (描述bug)**
--第一个class
struct data{
.....
}
class DemoTask {
public:
bthread::ExecutionQueueId> queue_id_one;
void start(){
bthread::execution_queue_start(&queue_id_one, nullptr, insertMongoDB, nullptr);
}
};
int consume(void* meta, TaskIterator& iter) {
if (iter.is_queue_stopped()) {
return 0;
}
for (; iter; ++iter) {
//这里使用mongo的C++驱动,将data的数据存入mongodb
//从配置读取db路径
//处理数据
}
return 0;
}
------第二个class
class request(){
private:
DemoTask task;
bthread::ExecutionQueueId> queue_id_one;
public:
defualt(){
task.start();
}
http(){
//将请求日志数据使用data
data .....
bthread::execution_queue_execute(queue_id_one, data );
}
}
----问题
1、第一次使用brpc,不太确定是否是因为使用方式不正确导致内存没有正常释放
2、测试环境在容器云上,内存是2G,压测27万次请求,内存从50mb逐步升到800mb,停止压测后,内存一直不会降下来(这次测试有一部分是因为日志数据插入太慢)
3、修改代码后,再次测试。内存从50mb涨到500mb,确认日志数据全部插入数据库了,但是内存任然没有降下来
4、我觉得是consume方法中创建的变量等,没有正常释放(我把方法中的逻辑全部删除测试过一次,内存一直在50mb左右,没有明显的增长)。不太理解完成一次任务后,任务中的变量等什么时机释放内存的。
**To Reproduce (复现方法)**
**Expected behavior (期望行为)**
了解内存不下降的原因,已经如何改进
**Versions (各种版本)**
OS:
Compiler:
brpc:1.6.1
protobuf:
**Additional context/screenshots (更多上下文/截图)**
Contributor guide
Research direction
Start with the reported bthread::ExecutionQueue usage in DemoTask and request, especially execution_queue_start, execution_queue_execute, and consume, using brpc 1.6.1. Reproduce the memory growth with the MongoDB C++ driver and profile after the queue drains; done means identifying whether the retained memory is from the queue, consumer work, or database driver and documenting the supported improvement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, mongodb
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100