【问题标题】:What do the fields in the output from `malloc_info` mean?`malloc_info` 输出中的字段是什么意思?
【发布时间】:2018-06-15 08:32:36
【问题描述】:

我正在调用 malloc_info(3) 并获取 XML 输出。

我在网上找到的所有内容都表明“这可能会发生变化,我们不会费心记录它”。

但这对于调查潜在内存碎片问题的人来说并不是非常有用。

这里有一些sn-ps:

<malloc version="1">
  <heap nr="0">
    <sizes>
      <size from="257" to="257" total="257" count="1"/>
    </sizes>
    <total type="fast" count="0" size="0"/>
    <total type="rest" count="1" size="257"/>
    <system type="current" size="303104"/>
    <system type="max" size="303104"/>
    <aspace type="total" size="303104"/>
    <aspace type="mprotect" size="303104"/>
  </heap>

  <heap nr="1">
    <sizes>
      <size from="17" to="32" total="96" count="3"/>
      <!-- etc. -->
      <size from="10609" to="10609" total="10609" count="1"/>
      <unsorted from="145" to="209" total="740" count="4"/>
    </sizes>
    <total type="fast" count="95" size="7328"/>
    <total type="rest" count="2633564" size="112589836"/>
    <system type="current" size="2032623616"/>
    <system type="max" size="2032947200"/>
    <aspace type="total" size="19451904"/>
    <aspace type="mprotect" size="19775488"/>
  </heap>

等等,等等,直到……


  <heap nr="27">
    <sizes>
</sizes>
    <total type="fast" count="0" size="0"/>
    <total type="rest" count="0" size="0"/>
    <system type="current" size="32768"/>
    <system type="max" size="32768"/>
    <aspace type="total" size="32768"/>
    <aspace type="mprotect" size="32768"/>
  </heap>
  <total type="fast" count="4232" size="293312"/>
  <total type="rest" count="22498068" size="1597097332"/>
  <system type="current" size="17265770496"/>
  <system type="max" size="17271173120"/>
  <aspace type="total" size="491339776"/>
  <aspace type="mprotect" size="496742400"/>
</malloc>

这一切究竟意味着什么?

我会在答案中加入一些我自己的笔记/想法,但如果有人比我了解更多,我将不胜感激。

ldd --version 报告 Ubuntu EGLIBC 2.19-0ubuntu6.13,这是我对 glibc 版本的最佳猜测。

我用 标记了它,因为它取自 Ubuntu 14.04,但它也可能与 相关。

【问题讨论】:

    标签: eglibc glibc malloc glibc eglibc


    【解决方案1】:

    http://core-analyzer.sourceforge.net/index_files/Page335.html 的图表相当有用。

    我很确定的事情:

    • Heap 0 是主要的竞技场。

      • 空闲块保存在“箱”中,按大小排列,以便快速重复使用。
      • 堆 0 有一个空闲块,大小为 257 字节。
      • 不知道currentmaxtotalmprotect是什么关系。
    • 其他堆从 1 开始编号。

    • 堆 1:

      • 一堆大小不一的空闲块。
      • fastrest 中的值跟踪空闲块的总大小:fast.count + rest.count == SUM(size.count)fast.size + rest.size == SUM(size.total)
      • 当前大小 = 2032623616 (~2GiB)
      • 总计(当前使用?)= 19451904 (~19MiB)
    • 堆 27:

      • 没有空闲块?
      • 分配了 32KiB,使用了 32KiB?
    • 总数?

      • ~17.2GiB 已分配?
      • ~491MiB 已使用?

    最后一个数字看起来不可靠;如果我总计使用的内存(通过其他方式),我得到〜3GiB。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 2021-12-15
    • 1970-01-01
    相关资源
    最近更新 更多