Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server 端通过channel 访问其他服务,内存持续缓慢上涨,疑似内存泄漏 #2633

Open
qhren opened this issue May 3, 2024 · 0 comments

Comments

@qhren
Copy link

qhren commented May 3, 2024

Describe the bug (描述bug)
服务运行一段时间后,内存持续上涨

To Reproduce (复现方法)
链接tcmalloc,打开fno-omit-frame-pointer 编译选项 和 heap profiler,对比前后的内存占用diff,发现内存消耗在channel init和channel call调用。
下图中的sumit_post_request的基本结构如下:

   baidu::rpc::Channel channel;
   baidu::rpc::ChannelOptions options;
   baidu::rpc::Controller cntl;
   options.protocol = baidu::rpc::PROTOCOL_HTTP;
   options.timeout_ms = 60000;
   options.max_retry = 3;

   if (channel.Init(uri.c_str(), "", &options) != 0) {
       CFATAL_LOG("init channel failed url = %s ", base_url.c_str());
       return ErrorCode::ERROR;
   }

   cntl.http_request().set_method(baidu::rpc::HTTP_METHOD_POST);
   cntl.http_request().uri() = base_url;
   cntl.http_request().set_content_type("application/json");  // set content type
   cntl.request_attachment().append(data_json_str);

   channel.CallMethod(NULL, &cntl, NULL, NULL, NULL);
   if (cntl.Failed()) {
       CFATAL_LOG("rpc failed error text = %s", cntl.ErrorText().c_str());
       ret_code = -1;
       return ErrorCode::ERROR;
   }

   o_res_json_str = cntl.response_attachment().to_string();
   ret_code = 200;
   return ErrorCode::SUCCESS;

Expected behavior (期望行为)
内存在服务压力变化不大的情况下基本维持稳定

Versions (各种版本)
OS:centos 6.3
Compiler: gcc12
brpc: stable 版本
protobuf: protobuf 2.4

Additional context/screenshots (更多上下文/截图)
heap profiler 时间:
image
内存占用对比差异:
image

@qhren qhren changed the title serve 端通过channel 访问其他服务,内存持续缓慢上涨,疑似内存泄漏 server 端通过channel 访问其他服务,内存持续缓慢上涨,疑似内存泄漏 May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant