From 5ce854f7b5f4d7bc24e36fe9af97f4da5bb73620 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Mon, 21 Mar 2022 09:32:54 -0300 Subject: [PATCH] feat: increase GC frequency when in low memory mode --- src/emqtt.erl | 3 ++- test/emqtt_SUITE.erl | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/emqtt.erl b/src/emqtt.erl index d7d83f92..e135b3fe 100644 --- a/src/emqtt.erl +++ b/src/emqtt.erl @@ -258,7 +258,8 @@ start_link(Options) when is_list(Options) -> false -> []; true -> [{spawn_opt, [{min_heap_size, 16}, - {min_bin_vheap_size,16} + {min_bin_vheap_size,16}, + {fullsweep_after, 1_000} ]}, {hibernate_after, 50} ] diff --git a/test/emqtt_SUITE.erl b/test/emqtt_SUITE.erl index caafca1e..95256e25 100644 --- a/test/emqtt_SUITE.erl +++ b/test/emqtt_SUITE.erl @@ -61,7 +61,8 @@ groups() -> t_stop, t_pause_resume, t_init, - t_connected]}, + t_connected, + t_low_mem_opts]}, {mqttv3,[non_parallel_tests], [basic_test_v3]}, {mqttv4, [non_parallel_tests], @@ -446,6 +447,12 @@ t_connected(Config) -> Clientid = gen_statem:call(C, clientid), [ ?assertMatch(Clientid, Value) || {Key, Value} <- emqtt:info(C), Key =:= clientid]. +t_low_mem_opts(Config) -> + Port = ?config(port, Config), + {ok, C} = emqtt:start_link([{port, Port}, {low_mem, true}]), + %% TODO: check min_heap_size, min_bin_vheap_size + ?assertEqual([{fullsweep_after, 1_000}], process_info(C, [fullsweep_after])). + t_inflight_full(_) -> error('TODO'). @@ -520,7 +527,7 @@ retry_interval_test(Config) -> timer:sleep(timer:seconds(2)), ?assertEqual(2, counters:get(CRef, 1)), - + meck:unload(emqtt_sock), meck:unload(emqtt_quic), ok = emqtt:disconnect(Pub).