简体   繁体   English

为什么 jeprof 评估的 jemalloc 内存配置文件似乎显示所有内存分配?

[英]Why does jemalloc memory profile evaluated by jeprof seem to show all memory allocations?

We are trying to track down a memory leak in proxysql (2.0.14) which uses jemalloc (5.2.0).我们正在尝试追踪使用 jemalloc (5.2.0) 的 proxysql (2.0.14) 中的内存泄漏。 We compiled proxysql with debug symbols enabled.我们在启用调试符号的情况下编译了proxysql。 The jemalloc configuration that is baked into proxysql is the following :嵌入到 proxysql 中的 jemalloc 配置如下

xmalloc:true,lg_tcache_max:16,prof:true,prof_leak:true,lg_prof_sample:20,lg_prof_interval:30,prof_active:false

The memory profiling is enabled at runtime with PROXYSQL MEMPROFILE START as can be seen here .该内存分析在运行时启用了PROXYSQL MEMPROFILE START可以看出这里 This sets memory profiling to active :这将内存分析设置为active

bool en=true;
mallctl("prof.active", NULL, NULL, &en, sizeof(bool));

This appears to work as the heap profile files are being generated, however when we analyse them with jeprof, it appears to log all memory allocations and not just the memory leaks.这似乎在生成堆配置文件时起作用,但是当我们使用 jeprof 分析它们时,它似乎记录了所有内存分配,而不仅仅是内存泄漏。 The pdf that we generated using jeprof can be found here .我们使用 jeprof 生成的 pdf 可以在这里找到。 As you can see, it seems like jeprof shows all of the memory allocations, instead of just the leaked ones.如您所见,jeprof 似乎显示了所有内存分配,而不仅仅是泄漏的内存分配。

From looking at other memory profiles , they display a smaller amount of memory total, whereas here in this profile we are seeing 21GB of total memory, which is more than what the server could allocate.通过查看其他内存配置文件,它们显示的内存总量较小,而在此配置文件中,我们看到 21GB 的总内存,这超过了服务器可以分配的内存量。 However, we are not sure where the problem lies - with jeprof, the configuration, or something else entirely.但是,我们不确定问题出在哪里 - jeprof、配置或其他完全不同的东西。

For reference we have added a sample heap profile here in case this will give an indication of what is going wrong.作为参考,我们 在此处添加了一个示例堆配置文件,以防万一这将指示出了什么问题。

I think this may reflect some of the ambiguity in what "leak" means.我认为这可能反映了“泄漏”含义的一些模糊性。 Tools like Valgrind will traverse the pointer graph of the program at shutdown, and treat things as leaks if that traversal does not find some live allocation. Valgrind 之类的工具将在关闭时遍历程序的指针图,如果遍历没有找到一些实时分配,则将其视为泄漏。

Other tools treat "leaks" as simply anything allocated but not freed.其他工具将“泄漏”视为已分配但未释放的任何内容。 The profiling mode in jemalloc works more like this way. jemalloc 中的分析模式更像是这样工作的。 It reports an estimation of the live bytes attributable to various call stacks at program termination.它报告了程序终止时可归因于各种调用堆栈的活动字节的估计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM