當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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}。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。