当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


erlang allocations(Options)用法及代码示例


allocations(Options) -> {ok, Result} | {error, Reason}
OTP 21.0
类型:
Result = allocation_summary()
Reason = not_enabled
Options = 
    #{scheduler_ids => [integer() >= 0],
      allocator_types => [atom()],
      histogram_start => integer() >= 1,
      histogram_width => integer() >= 1}

返回系统中所有标记分配的摘要,可以选择按分配器类型和调度程序 ID 进行过滤。

默认情况下,仅标记 NIF 和驱动程序进行的二进制文件和分配,但这可以使用 per-allocator 进行配置+M<S>atags 模拟器选项。

如果未启用指定的分配器类型,则调用将失败并显示 {error, not_enabled}

可以使用以下选项:


allocator_types

将搜索的分配器类型。

当启用不同分配器类型之间的载体迁移时,指定特定的分配器类型可能会导致奇怪的结果:您可能会看到意外的类型(例如,搜索binary_alloc时的进程堆),或者如果块所在的载体具有比预期更少的块已迁移到不同类型的分配器。

默认为所有 alloc_util 分配器。


scheduler_ids

将搜索其分配器实例的调度程序 ID。调度程序 ID 为 0 将引用未绑定到任何特定调度程序的全局实例。默认为所有调度程序和全局实例。


histogram_start

分配的块大小直方图中第一个区间的上限。默认为 128。


histogram_width

分配的块大小直方图中的间隔数。默认为 18。

例子:

> instrument:allocations(#{ histogram_start => 128, histogram_width => 15 }).
{ok,{128,0,
     #{udp_inet =>
           #{driver_event_state => {0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}},
       system =>
           #{heap => {0,0,0,0,20,4,2,2,2,3,0,1,0,0,1},
             db_term => {271,3,1,52,80,1,0,0,0,0,0,0,0,0,0},
             code => {0,0,0,5,3,6,11,22,19,20,10,2,1,0,0},
             binary => {18,0,0,0,7,0,0,1,0,0,0,0,0,0,0},
             message => {0,40,78,2,2,0,0,0,0,0,0,0,0,0,0},
             ... }
       spawn_forker =>
           #{driver_select_data_state =>
                 {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}},
       ram_file_drv => #{drv_binary => {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}},
       prim_file =>
           #{process_specific_data => {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
             nif_trap_export_entry => {0,4,0,0,0,0,0,0,0,0,0,0,0,0,0},
             monitor_extended => {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0},
             drv_binary => {0,0,0,0,0,0,1,0,3,5,0,0,0,1,0},
             binary => {0,4,0,0,0,0,0,0,0,0,0,0,0,0,0}},
       prim_buffer =>
           #{nif_internal => {0,4,0,0,0,0,0,0,0,0,0,0,0,0,0},
             binary => {0,4,0,0,0,0,0,0,0,0,0,0,0,0,0}}}}}

相关用法


注:本文由纯净天空筛选整理自erlang.org大神的英文原创作品 allocations(Options) -> {ok, Result} | {error, Reason}。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。