New to Elixir and OTP. Trying some hello-world examples with GenServer. I'm writing tests where each test spawns a GenServer process. They are not explicitly terminated. Will the process die after the test finishes?
Follow up: If it's not terminated, do they turn into "zombie" process? Also, is there a pattern for terminating them after the test completes?
No, processes are not garbage collected. Yes, they turn into "zombie" processes.
The pattern to prevent that is to link the processes. When one linked process terminates - all linked processes will terminate too. So if you start your server using
GenServer.start_link
from the test process - this will link the server process to the test process and when the test exists, the server will exit too.