Does anyone know if parked go blocks are eligible for garbage collection if you have no references to them?
Not sure. A parked block means it is parked on a put or take, which are compiled to callbacks registered on a channel. So the channel has a reference to the execution state
So seems like no, unless you also lose a lot of other related objects
In my case I am losing a lot of other related objects, so it might be fine.
I guess if I really want to know I should test it!
Report back :)
It looks like, yes, you definitely can have a core.async topology get garbage collected. I achieved this by leaving the topology blocked and discarding all (strong) references to it, then requesting garbage collection. In other words it works just as you might expect with no particular issues - if you can reach it then it is kept but if you can't then it will be cleared up at the JVMs leisure. My concern had been that escaping from a completely blocked topology following an error might leave some mess, but it appears that, once abandoned, the blocked topology can be cleared up by the JVM. So that's all fine.
Yes they are