|
35 | 35 | -export([get_total_memory/0, get_vm_limit/0,
|
36 | 36 | get_check_interval/0, set_check_interval/1,
|
37 | 37 | get_vm_memory_high_watermark/0, set_vm_memory_high_watermark/1,
|
38 |
| - get_memory_limit/0, get_memory_use/1, |
39 |
| - get_process_memory/0, get_memory_calculation_strategy/0]). |
| 38 | + get_memory_limit/0, |
| 39 | + %% TODO: refactor in master |
| 40 | + get_memory_use/1, |
| 41 | + get_process_memory/0, |
| 42 | + get_process_memory/1, |
| 43 | + get_memory_calculation_strategy/0]). |
40 | 44 |
|
41 | 45 | %% for tests
|
42 | 46 | -export([parse_line_linux/1, parse_mem_limit/1]).
|
|
60 | 64 |
|
61 | 65 | %%----------------------------------------------------------------------------
|
62 | 66 |
|
| 67 | +-type memory_calculation_strategy() :: rss | erlang | allocated. |
63 | 68 | -type vm_memory_high_watermark() :: (float() | {'absolute', integer() | string()}).
|
64 | 69 | -spec start_link(float()) -> rabbit_types:ok_pid_or_error().
|
65 | 70 | -spec start_link(float(), fun ((any()) -> 'ok'),
|
|
74 | 79 | -spec get_memory_use(bytes) -> {non_neg_integer(), float() | infinity};
|
75 | 80 | (ratio) -> float() | infinity.
|
76 | 81 | -spec get_cached_process_memory_and_limit() -> {non_neg_integer(), non_neg_integer()}.
|
| 82 | + |
| 83 | +-export_type([memory_calculation_strategy/0]). |
77 | 84 | %%----------------------------------------------------------------------------
|
78 | 85 | %% Public API
|
79 | 86 | %%----------------------------------------------------------------------------
|
@@ -142,7 +149,14 @@ get_process_memory() ->
|
142 | 149 | {ProcMem, _} = get_memory_use(bytes),
|
143 | 150 | ProcMem.
|
144 | 151 |
|
145 |
| --spec get_memory_calculation_strategy() -> rss | erlang. |
| 152 | +-spec get_process_memory(cached | current) -> Bytes :: integer(). |
| 153 | +get_process_memory(cached) -> |
| 154 | + {ProcMem, _} = get_memory_use(bytes), |
| 155 | + ProcMem; |
| 156 | +get_process_memory(current) -> |
| 157 | + get_process_memory_uncached(). |
| 158 | + |
| 159 | +-spec get_memory_calculation_strategy() -> memory_calculation_strategy(). |
146 | 160 | get_memory_calculation_strategy() ->
|
147 | 161 | case rabbit_misc:get_env(rabbit, vm_memory_calculation_strategy, rss) of
|
148 | 162 | allocated -> allocated;
|
|
0 commit comments