Afraid of leaks with async chan

96 views
Skip to first unread message

JokkeB

unread,
Oct 16, 2017, 5:32:26 AM10/16/17
to Clojure
I'm a bit unsure of which channels will be collected and which will remain and potentially result in an out of memory error. I'd like to understand when I should close, unsub and untap channels to avoid leaks. It feels like a very difficult task to verify there are no leaks.

For example:

(defn read-one-msg [source]
 
(let [c (async/chan)]
 
(async/sub source :msg c)
 
(async/<!! c)))

Will this leak c, should I manually unsub it?

I constantly stumble on this kind of questions so I'd like to understand better how to deal with these situations.
Reply all
Reply to author
Forward
0 new messages