Looking around some more: http://dieswaytoofast.blogspot.com/2012/12/erlang-binaries-and-garbage-collection.html
It turns out that refc-binaries keep track of every process that has ever touched them!
I know, its pretty obvious in retrospect, but the point here is that a refc-binary is not clobbered till every process that has ever touched it has been garbage-collected.
So that means whenever I want to ease binary memory in my app I’d need wait until all of these are garbage collected:
- the agent
- the controlling process
- each managed device process
- any other process that routes the binaries at all
…or just call :erlang.garbage_collect/0 myself periodically. I already have a timer in production that goes off periodically to check the number of open file descriptors for the application, I can probably make the change to call eval “:erlang.garbage_collect”, as most of the processes that touch the binaries are intended to be long-lived























