Skip to content

Commit 2cab2d9

Browse files
author
Daniil Fedotov
committed
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 0872a15 [addresses #1294] [#149066379]
1 parent 1532037 commit 2cab2d9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/rabbit_vm.erl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,22 @@ memory() ->
5151
0
5252
end,
5353
MgmtDbETS = ets_memory([rabbit_mgmt_storage]),
54-
OsTotal = vm_memory_monitor:get_process_memory(),
54+
VMTotal = vm_memory_monitor:get_process_memory(),
5555

5656

57-
[{processes, Processes},
57+
[{total, ErlangTotal},
58+
{processes, Processes},
5859
{ets, ETS},
5960
{atom, Atom},
6061
{binary, Bin},
6162
{code, Code},
6263
{system, System}] =
63-
erlang:memory([processes, ets, atom, binary, code, system]),
64+
erlang:memory([total, processes, ets, atom, binary, code, system]),
65+
66+
Unaccounted = case VMTotal - ErlangTotal of
67+
GTZ when GTZ > 0 -> GTZ;
68+
_LTZ -> 0
69+
end,
6470

6571
OtherProc = Processes
6672
- ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
@@ -96,9 +102,9 @@ memory() ->
96102
%% System
97103
{code, Code},
98104
{atom, Atom},
99-
{other_system, System - ETS - Bin - Code - Atom},
105+
{other_system, System - ETS - Bin - Code - Atom + Unaccounted},
100106

101-
{total, OsTotal}
107+
{total, VMTotal}
102108
].
103109
%% [1] - erlang:memory(processes) can be less than the sum of its
104110
%% parts. Rather than display something nonsensical, just silence any

0 commit comments

Comments
 (0)