summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Fedotov <dfedotov@pivotal.io>2017-10-25 16:29:55 +0100
committerDaniil Fedotov <dfedotov@pivotal.io>2017-10-25 16:42:01 +0100
commitd8f2852c6df9346b13168e554a29b21c118b60bd (patch)
treed022ea8f69c9ac8e7ab081f76860206a5013792b /src
parentb55f79da5fd50ead74308d8ad3bcf7121dac38c4 (diff)
downloadrabbitmq-server-git-d8f2852c6df9346b13168e554a29b21c118b60bd.tar.gz
Add more sections to the memory breakdown.
If a node memory is measured using `allocator` or `rss` strategies, we can calculate unused memory and report it separately in the memory breakdown.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_vm.erl58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/rabbit_vm.erl b/src/rabbit_vm.erl
index 685cea2ea7..c2fee7d527 100644
--- a/src/rabbit_vm.erl
+++ b/src/rabbit_vm.erl
@@ -51,9 +51,6 @@ memory() ->
0
end,
MgmtDbETS = ets_memory([rabbit_mgmt_storage]),
- VMTotal = vm_memory_monitor:get_process_memory(),
-
-
[{total, ErlangTotal},
{processes, Processes},
{ets, ETS},
@@ -63,48 +60,59 @@ memory() ->
{system, System}] =
erlang:memory([total, processes, ets, atom, binary, code, system]),
- Unaccounted = case VMTotal - ErlangTotal of
- GTZ when GTZ > 0 -> GTZ;
- _LTZ -> 0
+ Strategy = vm_memory_monitor:get_memory_calculation_strategy(),
+ {Allocated, VMTotal} = case Strategy of
+ erlang -> {ErlangTotal, ErlangTotal};
+ allocated ->
+ Alloc = recon_alloc:memory(allocated),
+ {Alloc, Alloc};
+ rss ->
+ Alloc = recon_alloc:memory(allocated),
+ Vm = vm_memory_monitor:get_process_memory(current),
+ {Alloc, Vm}
end,
+ AllocatedUnused = max(Allocated - ErlangTotal, 0),
+ OSReserved = max(VMTotal - Allocated, 0),
+
OtherProc = Processes
- ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
- Qs - QsSlave - MsgIndexProc - Plugins - MgmtDbProc - MetricsProc,
[
%% Connections
- {connection_readers, ConnsReader},
- {connection_writers, ConnsWriter},
- {connection_channels, ConnsChannel},
- {connection_other, ConnsOther},
+ {connection_readers, ConnsReader},
+ {connection_writers, ConnsWriter},
+ {connection_channels, ConnsChannel},
+ {connection_other, ConnsOther},
%% Queues
- {queue_procs, Qs},
- {queue_slave_procs, QsSlave},
+ {queue_procs, Qs},
+ {queue_slave_procs, QsSlave},
%% Processes
- {plugins, Plugins},
- {other_proc, lists:max([0, OtherProc])}, %% [1]
+ {plugins, Plugins},
+ {other_proc, lists:max([0, OtherProc])}, %% [1]
%% Metrics
- {metrics, MetricsETS + MetricsProc},
- {mgmt_db, MgmtDbETS + MgmtDbProc},
+ {metrics, MetricsETS + MetricsProc},
+ {mgmt_db, MgmtDbETS + MgmtDbProc},
%% ETS
- {mnesia, MnesiaETS},
- {other_ets, ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS},
+ {mnesia, MnesiaETS},
+ {other_ets, ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS},
%% Messages (mostly, some binaries are not messages)
- {binary, Bin},
- {msg_index, MsgIndexETS + MsgIndexProc},
+ {binary, Bin},
+ {msg_index, MsgIndexETS + MsgIndexProc},
%% System
- {code, Code},
- {atom, Atom},
- {other_system, System - ETS - Bin - Code - Atom + Unaccounted},
-
- {total, VMTotal}
+ {code, Code},
+ {atom, Atom},
+ {other_system, System - ETS - Bin - Code - Atom},
+ {allocated_unused, AllocatedUnused},
+ {reserved_unallocated, OSReserved},
+ {total, VMTotal}
].
%% [1] - erlang:memory(processes) can be less than the sum of its
%% parts. Rather than display something nonsensical, just silence any