> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# memory_profiler_* 会话设置

> ClickHouse 在 memory_profiler_* 分组中的会话设置。

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

这些设置可在 [system.settings](/docs/zh/reference/system-tables/settings) 中查看，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="memory_profiler_sample_max_allocation_size">
  ## memory\_profiler\_sample\_max\_allocation\_size
</div>

<SettingsInfoBlock type="UInt64" default_value="0" />

以 `memory_profiler_sample_probability` 指定的概率，收集大小小于或等于指定值的随机内存分配。0 表示禁用。你可能需要将 `max_untracked_memory` 设为 0，以确保此阈值按预期生效。

<div id="memory_profiler_sample_min_allocation_size">
  ## memory\_profiler\_sample\_min\_allocation\_size
</div>

<SettingsInfoBlock type="UInt64" default_value="0" />

以 `memory_profiler_sample_probability` 指定的概率，对大小大于或等于指定值的随机内存分配进行采样。0 表示禁用。你可能需要将 `max_untracked_memory` 设置为 0，以使此阈值按预期生效。

<div id="memory_profiler_sample_probability">
  ## memory\_profiler\_sample\_probability
</div>

<SettingsInfoBlock type="Float" default_value="0" />

对随机的内存分配和释放进行采样，并以 'MemorySample' trace\_type 写入 system.trace\_log。该概率适用于每次 alloc/free，与分配大小无关 (可通过 `memory_profiler_sample_min_allocation_size` 和 `memory_profiler_sample_max_allocation_size` 调整) 。请注意，只有当未跟踪内存量超过 'max\_untracked\_memory' 时才会发生采样。若要获得更细粒度的采样，你可能需要将 'max\_untracked\_memory' 设为 0。

<div id="memory_profiler_step">
  ## memory\_profiler\_step
</div>

<SettingsInfoBlock type="UInt64" default_value="4194304" />

设置内存分析器的步长。每当查询的内存使用量增加到超过按字节数划分的下一个步长时，内存分析器都会采集分配时的 stacktrace，并将其写入 [trace\_log](/docs/zh/reference/system-tables/trace_log)。

可能的值：

* 以字节为单位的正整数。

* 0 表示关闭内存分析器。
