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

Commit fbca905

Browse files
Merge pull request #229 from rabbitmq/rabbitmq-common-224-compat-fixes
Fix issues uncovered after merging #224
2 parents 99d0bdd + 022d538 commit fbca905

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/vm_memory_monitor.erl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ set_vm_memory_high_watermark(Fraction) ->
113113
get_memory_limit() ->
114114
gen_server:call(?MODULE, get_memory_limit, infinity).
115115

116-
get_cached_process_memory_and_limit() ->
117-
gen_server:call(?MODULE, get_cached_process_memory_and_limit, infinity).
118-
119116
get_memory_use(bytes) ->
120117
{ProcessMemory, MemoryLimit} = get_cached_process_memory_and_limit(),
121118
{ProcessMemory, case MemoryLimit > 0.0 of
@@ -142,13 +139,8 @@ get_memory_use(ratio) ->
142139
%% for details.
143140
-spec get_process_memory() -> Bytes :: integer().
144141
get_process_memory() ->
145-
try
146-
{ProcMem, _} = get_memory_use(bytes),
147-
ProcMem
148-
catch exit:{noproc, Error} ->
149-
rabbit_log:warning("Memory monitor process not yet started: ~p~n", [Error]),
150-
get_process_memory_uncached()
151-
end.
142+
{ProcMem, _} = get_memory_use(bytes),
143+
ProcMem.
152144

153145
-spec get_memory_calculation_strategy() -> rss | erlang.
154146
get_memory_calculation_strategy() ->
@@ -239,6 +231,15 @@ code_change(_OldVsn, State, _Extra) ->
239231
%% Server Internals
240232
%%----------------------------------------------------------------------------
241233

234+
get_cached_process_memory_and_limit() ->
235+
try
236+
gen_server:call(?MODULE, get_cached_process_memory_and_limit, infinity)
237+
catch exit:{noproc, Error} ->
238+
rabbit_log:warning("Memory monitor process not yet started: ~p~n", [Error]),
239+
ProcessMemory = get_process_memory_uncached(),
240+
{ProcessMemory, infinity}
241+
end.
242+
242243
get_process_memory_uncached() ->
243244
TmpState = init_state_by_os(#state{}),
244245
TmpState#state.process_memory.
@@ -264,7 +265,7 @@ get_process_memory_using_strategy(rss, #state{os_type = {unix, linux},
264265
page_size = PageSize,
265266
proc_file = ProcFile}) ->
266267
Data = read_proc_file(ProcFile),
267-
[_|[RssPagesStr|_]] = string:split(Data, " ", all),
268+
[_|[RssPagesStr|_]] = string:tokens(Data, " "),
268269
ProcMem = list_to_integer(RssPagesStr) * PageSize,
269270
{ok, ProcMem};
270271
get_process_memory_using_strategy(rss, #state{os_type = {unix, _},

0 commit comments

Comments
 (0)