[fix](memory) Fix memory leak by calling boost::stacktrace (#14269)

boost::stacktrace::stacktrace() has memory leak, so use glog internal func to print stacktrace.
The reason for the memory leak of boost::stacktrace is that a state is saved in the thread local of each thread but not actively released. The test found that each thread leaked about 100M after calling boost::stacktrace.
refer to:
boostorg/stacktrace#118
boostorg/stacktrace#111
This commit is contained in:
Xinyi Zou
2022-11-15 08:58:57 +08:00
committed by GitHub
parent 93e5d8e660
commit cffdeff4ec
9 changed files with 49 additions and 44 deletions

View File

@ -25,6 +25,11 @@ void DumpStackTraceToString(std::string* stacktrace);
namespace doris {
// `boost::stacktrace::stacktrace()` has memory leak, so use the glog internal func to print stacktrace.
// The reason for the boost::stacktrace memory leak is that a state is saved in the thread local of each
// thread but is not actively released. Refer to:
// https://github.com/boostorg/stacktrace/issues/118
// https://github.com/boostorg/stacktrace/issues/111
std::string get_stack_trace() {
std::string s;
google::glog_internal_namespace_::DumpStackTraceToString(&s);