@@ -51,9 +51,6 @@ memory() ->
5151 0
5252 end ,
5353 MgmtDbETS = ets_memory ([rabbit_mgmt_storage ]),
54- VMTotal = vm_memory_monitor :get_process_memory (),
55-
56-
5754 [{total , ErlangTotal },
5855 {processes , Processes },
5956 {ets , ETS },
@@ -63,48 +60,59 @@ memory() ->
6360 {system , System }] =
6461 erlang :memory ([total , processes , ets , atom , binary , code , system ]),
6562
66- Unaccounted = case VMTotal - ErlangTotal of
67- GTZ when GTZ > 0 -> GTZ ;
68- _LTZ -> 0
63+ Strategy = vm_memory_monitor :get_memory_calculation_strategy (),
64+ {Allocated , VMTotal } = case Strategy of
65+ erlang -> {ErlangTotal , ErlangTotal };
66+ allocated ->
67+ Alloc = recon_alloc :memory (allocated ),
68+ {Alloc , Alloc };
69+ rss ->
70+ Alloc = recon_alloc :memory (allocated ),
71+ Vm = vm_memory_monitor :get_process_memory (current ),
72+ {Alloc , Vm }
6973 end ,
7074
75+ AllocatedUnused = max (Allocated - ErlangTotal , 0 ),
76+ OSReserved = max (VMTotal - Allocated , 0 ),
77+
7178 OtherProc = Processes
7279 - ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
7380 - Qs - QsSlave - MsgIndexProc - Plugins - MgmtDbProc - MetricsProc ,
7481
7582 [
7683 % % Connections
77- {connection_readers , ConnsReader },
78- {connection_writers , ConnsWriter },
79- {connection_channels , ConnsChannel },
80- {connection_other , ConnsOther },
84+ {connection_readers , ConnsReader },
85+ {connection_writers , ConnsWriter },
86+ {connection_channels , ConnsChannel },
87+ {connection_other , ConnsOther },
8188
8289 % % Queues
83- {queue_procs , Qs },
84- {queue_slave_procs , QsSlave },
90+ {queue_procs , Qs },
91+ {queue_slave_procs , QsSlave },
8592
8693 % % Processes
87- {plugins , Plugins },
88- {other_proc , lists :max ([0 , OtherProc ])}, % % [1]
94+ {plugins , Plugins },
95+ {other_proc , lists :max ([0 , OtherProc ])}, % % [1]
8996
9097 % % Metrics
91- {metrics , MetricsETS + MetricsProc },
92- {mgmt_db , MgmtDbETS + MgmtDbProc },
98+ {metrics , MetricsETS + MetricsProc },
99+ {mgmt_db , MgmtDbETS + MgmtDbProc },
93100
94101 % % ETS
95- {mnesia , MnesiaETS },
96- {other_ets , ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS },
102+ {mnesia , MnesiaETS },
103+ {other_ets , ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS },
97104
98105 % % Messages (mostly, some binaries are not messages)
99- {binary , Bin },
100- {msg_index , MsgIndexETS + MsgIndexProc },
106+ {binary , Bin },
107+ {msg_index , MsgIndexETS + MsgIndexProc },
101108
102109 % % System
103- {code , Code },
104- {atom , Atom },
105- {other_system , System - ETS - Bin - Code - Atom + Unaccounted },
106-
107- {total , VMTotal }
110+ {code , Code },
111+ {atom , Atom },
112+ {other_system , System - ETS - Bin - Code - Atom },
113+ {allocated_unused , AllocatedUnused },
114+ {reserved_unallocated , OSReserved },
115+ {total , VMTotal }
108116 ].
109117% % [1] - erlang:memory(processes) can be less than the sum of its
110118% % parts. Rather than display something nonsensical, just silence any
0 commit comments