diff options
| author | Michael Klishin <michael@novemberain.com> | 2017-10-26 16:46:16 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-26 16:46:16 +0300 |
| commit | c06a1f11c81e13d6b420ecec0d1e69f36865d7d7 (patch) | |
| tree | 4d486cf39e0c23786834dcb4fb0430d443241f9d | |
| parent | 2545c1b136f4993019bf8368057def2a546ed9f8 (diff) | |
| parent | d8f2852c6df9346b13168e554a29b21c118b60bd (diff) | |
| download | rabbitmq-server-git-c06a1f11c81e13d6b420ecec0d1e69f36865d7d7.tar.gz | |
Merge pull request #1404 from rabbitmq/rabbitmq-management-499
Add more sections to the memory breakdown.
| -rw-r--r-- | src/rabbit_vm.erl | 58 |
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 |
