Fork me on GitHub
#clojure-dev
<
2020-03-19
>
rutledgepaulv18:03:48

Hi all, I’ve been debugging a memory leak in my application and have traced it back to agent executor threads still referring to the state I’m maintaining in agents. I noticed that clojure.core/send-via uses clojure.core/binding-conveyer-fn which sets the thread local bindings but never pops them. Can someone help me understand why bound-fn* isn’t used instead so that any thread locals on agent executor threads are cleared when the agent is done processing the message? Related: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2103-L2111 https://clojure.atlassian.net/browse/CLJ-1125 https://groups.google.com/forum/#!topic/clojure-dev/3CXDe8_9G58/discussion

rutledgepaulv18:03:17

hmm, I see now that Toby hinted at the difficulty being that if the function that was sent to the agent throws an exception, the bindings are still expected to be set when caught by the error handler. if the sent function popped them then they wouldn’t be available anymore to the error handler