From a73b28789de104f5e760df5d1ca5bab9c7b66f58 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Sun, 18 Sep 2022 10:04:15 +0800 Subject: [PATCH] Fix memory leak by calling in mem hook (#12708) After the consume mem tracker exceeds the mem limit in the mem hook, the boost stacktrace will be printed. A query/load will only be printed once, and the process tracker will only be printed once per second. After the process memory reaches the upper limit, the boost stacktrace will be printed every second. The observed phenomena are as follows: After query/load is canceled, the memory increases instantly; tcmalloc profile total physical memory is less than perf process memory; The process mem tracker is smaller than the perf process memory; --- be/src/runtime/memory/mem_tracker_limiter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/be/src/runtime/memory/mem_tracker_limiter.cpp b/be/src/runtime/memory/mem_tracker_limiter.cpp index e09e1493c8..a1fdb60f9d 100644 --- a/be/src/runtime/memory/mem_tracker_limiter.cpp +++ b/be/src/runtime/memory/mem_tracker_limiter.cpp @@ -213,7 +213,8 @@ void MemTrackerLimiter::print_log_usage(const std::string& msg) { } else { detail += "\n" + log_usage(); } - detail += "\n" + boost::stacktrace::to_string(boost::stacktrace::stacktrace()); + // TODO: memory leak by calling `boost::stacktrace` in mem hook + // detail += "\n" + boost::stacktrace::to_string(boost::stacktrace::stacktrace()); LOG(WARNING) << detail; _print_log_usage = false; }