Skip to content

Commit ce5d42a

Browse files
committed
Hibernate after collecting garbage in rabbit_mgmt_gc
The `rabbit_mgmt_gc` gen_server performs garbage collections periodically. When doing so it can create potentially fairly large terms, for example by creating a set out of `rabbit_exchange:list_names/0`. With many exchanges, for example, the process memory usage can climb steadily especially when the management agent is mostly idle since `rabbit_mgmt_gc` won't hit enough reductions to cause a full-sweep GC on itself. Since the process is only active periodically (once every 2min by default) we can hibernate it to GC the terms it created. This can save a medium amount of memory in situations where there are very many pieces of metadata (exchanges, vhosts, queues, etc.). For example on an idle single-node broker with 50k exchanges, `rabbit_mgmt_gc` can hover around 50MB before being naturally GC'd. With this patch the process memory usage stays consistent between `start_gc` timer messages at around 1KB.
1 parent 98d1634 commit ce5d42a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

deps/rabbitmq_management_agent/src/rabbit_mgmt_gc.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ handle_info(start_gc, State) ->
3636
gc_queues(),
3737
gc_exchanges(),
3838
gc_nodes(),
39-
{noreply, start_timer(State)}.
39+
{noreply, start_timer(State), hibernate}.
4040

4141
terminate(_Reason, #state{timer = TRef}) ->
4242
_ = erlang:cancel_timer(TRef),

0 commit comments

Comments
 (0)