summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@clojurewerkz.org>2017-10-26 17:06:55 +0300
committerMichael Klishin <michael@clojurewerkz.org>2017-10-26 17:06:55 +0300
commit21879a91b19b4c959d7b66d73a31b638cb4f4dcf (patch)
tree0850d029b1d4c4d5a9f809093b05b43f11cb503b
parentcb8de07dbb357edd1202baa0bdc487d80a861285 (diff)
parentc06a1f11c81e13d6b420ecec0d1e69f36865d7d7 (diff)
downloadrabbitmq-server-git-21879a91b19b4c959d7b66d73a31b638cb4f4dcf.tar.gz
Merge branch 'stable'
Conflicts: src/rabbit_vm.erl
-rw-r--r--src/rabbit_vm.erl57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/rabbit_vm.erl b/src/rabbit_vm.erl
index 88062dc32a..b2474a6b38 100644
--- a/src/rabbit_vm.erl
+++ b/src/rabbit_vm.erl
@@ -51,8 +51,6 @@ memory() ->
0
end,
MgmtDbETS = ets_memory([rabbit_mgmt_storage]),
- VMTotal = vm_memory_monitor:get_process_memory(),
-
[{total, ErlangTotal},
{processes, Processes},
{ets, ETS},
@@ -62,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