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