Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 81e7d86

Browse files
Merge pull request #236 from rabbitmq/rabbitmq-management-499
An API to get non-cached process memory.
2 parents 8149bfe + 4ec12a8 commit 81e7d86

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/vm_memory_monitor.erl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@
3535
-export([get_total_memory/0, get_vm_limit/0,
3636
get_check_interval/0, set_check_interval/1,
3737
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]).
4044

4145
%% for tests
4246
-export([parse_line_linux/1, parse_mem_limit/1]).
@@ -60,6 +64,7 @@
6064

6165
%%----------------------------------------------------------------------------
6266

67+
-type memory_calculation_strategy() :: rss | erlang | allocated.
6368
-type vm_memory_high_watermark() :: (float() | {'absolute', integer() | string()}).
6469
-spec start_link(float()) -> rabbit_types:ok_pid_or_error().
6570
-spec start_link(float(), fun ((any()) -> 'ok'),
@@ -74,6 +79,8 @@
7479
-spec get_memory_use(bytes) -> {non_neg_integer(), float() | infinity};
7580
(ratio) -> float() | infinity.
7681
-spec get_cached_process_memory_and_limit() -> {non_neg_integer(), non_neg_integer()}.
82+
83+
-export_type([memory_calculation_strategy/0]).
7784
%%----------------------------------------------------------------------------
7885
%% Public API
7986
%%----------------------------------------------------------------------------
@@ -142,7 +149,14 @@ get_process_memory() ->
142149
{ProcMem, _} = get_memory_use(bytes),
143150
ProcMem.
144151

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().
146160
get_memory_calculation_strategy() ->
147161
case rabbit_misc:get_env(rabbit, vm_memory_calculation_strategy, rss) of
148162
allocated -> allocated;

0 commit comments

Comments
 (0)