summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Fedotov <dfedotov@pivotal.io>2017-07-18 12:26:26 +0100
committerDaniil Fedotov <dfedotov@pivotal.io>2017-07-18 12:35:47 +0100
commit2cab2d9b9a6dd58a632a76a567acdc086052c374 (patch)
tree003e4664d6ff2dfee1107d7f0dc0a88f2780c3b6 /src
parent1532037fec1291641d55f460046070902081b5e3 (diff)
downloadrabbitmq-server-git-2cab2d9b9a6dd58a632a76a567acdc086052c374.tar.gz
Report a difference between RSS and erlang total memory only if RSS is bigger.
RSS can be either bigger than memory reported by `erlang:memory(total)` or smaller. Make sure we only add positive difference to "other" fraction in memory breakdown. Related to 0872a15a050176ab7598bc3d1b21a2d5c5af3052 [addresses #1294] [#149066379]
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_vm.erl16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rabbit_vm.erl b/src/rabbit_vm.erl
index 74d29f5be4..685cea2ea7 100644
--- a/src/rabbit_vm.erl
+++ b/src/rabbit_vm.erl
@@ -51,16 +51,22 @@ memory() ->
0
end,
MgmtDbETS = ets_memory([rabbit_mgmt_storage]),
- OsTotal = vm_memory_monitor:get_process_memory(),
+ VMTotal = vm_memory_monitor:get_process_memory(),
- [{processes, Processes},
+ [{total, ErlangTotal},
+ {processes, Processes},
{ets, ETS},
{atom, Atom},
{binary, Bin},
{code, Code},
{system, System}] =
- erlang:memory([processes, ets, atom, binary, code, system]),
+ erlang:memory([total, processes, ets, atom, binary, code, system]),
+
+ Unaccounted = case VMTotal - ErlangTotal of
+ GTZ when GTZ > 0 -> GTZ;
+ _LTZ -> 0
+ end,
OtherProc = Processes
- ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
@@ -96,9 +102,9 @@ memory() ->
%% System
{code, Code},
{atom, Atom},
- {other_system, System - ETS - Bin - Code - Atom},
+ {other_system, System - ETS - Bin - Code - Atom + Unaccounted},
- {total, OsTotal}
+ {total, VMTotal}
].
%% [1] - erlang:memory(processes) can be less than the sum of its
%% parts. Rather than display something nonsensical, just silence any