Phoenix.socket Garbage collection. When to use it

Hello everybody!
My question is the same like a title of the post )). I found in documentation section about garbage collection https://hexdocs.pm/phoenix/Phoenix.Transports.WebSocket.html#module-garbage-collection, but i am not sure i understand when should i use it and how to?

So, what if we do have large message passing through sockets, should we manually initiate garbage collection after we did a broadcast? And what might happen if we will not do it? Does it make some kind of memory leak?

Elixir/Erlang’s garbage collection usually works quite well without manual interference.

Are you experiencing any issues with websockets using up too much memory? If not, I wouldn’t worry about it now. But you can always keep in mind that there is a way to manually garbage collect a socket process, should the need come up at some point.

1 Like