@@ -51,8 +51,6 @@ memory() ->
51
51
0
52
52
end ,
53
53
MgmtDbETS = ets_memory ([rabbit_mgmt_storage ]),
54
- VMTotal = vm_memory_monitor :get_process_memory (),
55
-
56
54
[{total , ErlangTotal },
57
55
{processes , Processes },
58
56
{ets , ETS },
@@ -62,48 +60,59 @@ memory() ->
62
60
{system , System }] =
63
61
erlang :memory ([total , processes , ets , atom , binary , code , system ]),
64
62
65
- Unaccounted = case VMTotal - ErlangTotal of
66
- GTZ when GTZ > 0 -> GTZ ;
67
- _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 }
68
73
end ,
69
74
75
+ AllocatedUnused = max (Allocated - ErlangTotal , 0 ),
76
+ OSReserved = max (VMTotal - Allocated , 0 ),
77
+
70
78
OtherProc = Processes
71
79
- ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
72
80
- Qs - QsSlave - MsgIndexProc - Plugins - MgmtDbProc - MetricsProc ,
73
81
74
82
[
75
83
% % Connections
76
- {connection_readers , ConnsReader },
77
- {connection_writers , ConnsWriter },
78
- {connection_channels , ConnsChannel },
79
- {connection_other , ConnsOther },
84
+ {connection_readers , ConnsReader },
85
+ {connection_writers , ConnsWriter },
86
+ {connection_channels , ConnsChannel },
87
+ {connection_other , ConnsOther },
80
88
81
89
% % Queues
82
- {queue_procs , Qs },
83
- {queue_slave_procs , QsSlave },
90
+ {queue_procs , Qs },
91
+ {queue_slave_procs , QsSlave },
84
92
85
93
% % Processes
86
- {plugins , Plugins },
87
- {other_proc , lists :max ([0 , OtherProc ])}, % % [1]
94
+ {plugins , Plugins },
95
+ {other_proc , lists :max ([0 , OtherProc ])}, % % [1]
88
96
89
97
% % Metrics
90
- {metrics , MetricsETS + MetricsProc },
91
- {mgmt_db , MgmtDbETS + MgmtDbProc },
98
+ {metrics , MetricsETS + MetricsProc },
99
+ {mgmt_db , MgmtDbETS + MgmtDbProc },
92
100
93
101
% % ETS
94
- {mnesia , MnesiaETS },
95
- {other_ets , ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS },
102
+ {mnesia , MnesiaETS },
103
+ {other_ets , ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS },
96
104
97
105
% % Messages (mostly, some binaries are not messages)
98
- {binary , Bin },
99
- {msg_index , MsgIndexETS + MsgIndexProc },
106
+ {binary , Bin },
107
+ {msg_index , MsgIndexETS + MsgIndexProc },
100
108
101
109
% % System
102
- {code , Code },
103
- {atom , Atom },
104
- {other_system , System - ETS - Bin - Code - Atom + Unaccounted },
105
-
106
- {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 }
107
116
].
108
117
% % [1] - erlang:memory(processes) can be less than the sum of its
109
118
% % parts. Rather than display something nonsensical, just silence any
0 commit comments