Hi!
I did a simple test: send `rename` message to actor 1000000 times. Rename handler changes internal variable value to new name and sends notifications to a couple of other actors.
Test runs through 3 stages:
1. Send `rename` messages 1000000 times in a loop (processing of sent messages also starts in background).
2. Loop already fiished, but messages are still being processed by CAF runtime (call await_all_actors_done())
3. Destroy `actor_system` and exit.
What I see is that memory is growing constantly during stages 1 and 2. At some point on stage 2 it reaches a limit and keeps at that value. Then, in the very end of step 2 large amount of memory is released and the rest lesser amount is released on step 3, so no leak actually occurs.
Gepftools heap profiler gives me the following top 3 memory consumers (during step 2):
Total: 400.0 MB
160.6 40.2% 40.2% 160.6 40.2% caf::make_message
112.6 28.1% 68.3% 112.6 28.1% caf::make_mailbox_element
101.5 25.4% 93.7% 101.5 25.4% caf::make_counted
Then, right after `await_all_actors_done()` finishes, I see that top 3 freed it's memory:
Total: -300.9 MB
66.1 -22.0% -22.0% 66.1 -22.0% caf::detail::thread_safe_actor_clock::run_dispatch_loop
33.0 -11.0% -32.9% 33.0 -11.0% caf::detail::thread_safe_actor_clock::set_request_timeout
-101.5 33.7% 9.2% -101.5 33.7% caf::make_counted
-112.6 37.4% 46.6% -112.6 37.4% caf::make_mailbox_element
-160.6 53.4% 100.0% -160.6 53.4% caf::make_message
Then, on step 3 more memory is freed:
Total: -99.1 MB
-33.0 33.3% 33.3% -33.0 33.3% caf::detail::thread_safe_actor_clock::set_request_timeout
-66.1 66.7% 100.0% -66.1 66.7% caf::detail::thread_safe_actor_clock::run_dispatch_loop
(here I listed only CAF-related top-consumers).
Can you please explain why this happens and is it normal? Even though no leaks are detected, behaivour like that (memory consumption growing) is sometimes not desired. Are there any memory-related knobs in CAF to limit memory consumption or turn on more frequent cleanup, etc?