3030
3131% %----------------------------------------------------------------------------
3232
33- % % Like erlang:memory(), but with awareness of rabbit-y things
3433memory () ->
3534 All = interesting_sups (),
3635 {Sums , _Other } = sum_processes (
@@ -41,7 +40,7 @@ memory() ->
4140 [aggregate (Names , Sums , memory , fun (X ) -> X end )
4241 || Names <- distinguished_interesting_sups ()],
4342
44- Mnesia = mnesia_memory (),
43+ MnesiaETS = mnesia_memory (),
4544 MsgIndexETS = ets_memory ([msg_store_persistent , msg_store_transient ]),
4645 MetricsETS = ets_memory ([rabbit_metrics ]),
4746 MetricsProc = try
@@ -52,8 +51,10 @@ memory() ->
5251 0
5352 end ,
5453 MgmtDbETS = ets_memory ([rabbit_mgmt_storage ]),
54+ {OsTotal , _ } = vm_memory_monitor :get_memory_use (bytes ),
5555
56- [{total , Total },
56+
57+ [{total , ErlangTotal },
5758 {processes , Processes },
5859 {ets , ETS },
5960 {atom , Atom },
@@ -66,24 +67,40 @@ memory() ->
6667 - ConnsReader - ConnsWriter - ConnsChannel - ConnsOther
6768 - Qs - QsSlave - MsgIndexProc - Plugins - MgmtDbProc - MetricsProc ,
6869
69- [{total , Total },
70+ [
71+ % % Connections
7072 {connection_readers , ConnsReader },
7173 {connection_writers , ConnsWriter },
7274 {connection_channels , ConnsChannel },
7375 {connection_other , ConnsOther },
76+
77+ % % Queues
7478 {queue_procs , Qs },
7579 {queue_slave_procs , QsSlave },
80+
81+ % % Processes
7682 {plugins , Plugins },
7783 {other_proc , lists :max ([0 , OtherProc ])}, % % [1]
78- {mnesia , Mnesia },
84+
85+ % % Metrics
7986 {metrics , MetricsETS + MetricsProc },
8087 {mgmt_db , MgmtDbETS + MgmtDbProc },
81- {msg_index , MsgIndexETS + MsgIndexProc },
82- {other_ets , ETS - Mnesia - MsgIndexETS - MgmtDbETS },
88+
89+ % % ETS
90+ {mnesia , MnesiaETS },
91+ {other_ets , ETS - MnesiaETS - MetricsETS - MgmtDbETS - MsgIndexETS },
92+
93+ % % Messages (mostly, some binaries are not messages)
8394 {binary , Bin },
95+ {msg_index , MsgIndexETS + MsgIndexProc },
96+
97+ % % System
8498 {code , Code },
8599 {atom , Atom },
86- {other_system , System - ETS - Atom - Bin - Code }].
100+ {other_system , System - ETS - Bin - Code - Atom + (OsTotal - ErlangTotal )},
101+
102+ {total , OsTotal }
103+ ].
87104
88105% % [1] - erlang:memory(processes) can be less than the sum of its
89106% % parts. Rather than display something nonsensical, just silence any
0 commit comments