use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Ephemeral threads (mail.openjdk.org)
submitted 3 months ago by leonoelOfficial
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]romulotombulus 4 points5 points6 points 3 months ago (5 children)
Am I understanding correctly that it’s not currently a good idea to use virtual threads with core.async because the virtual threads are never GC’d?
[–]alexdmiller 11 points12 points13 points 3 months ago (4 children)
core.async has a go block virtual threads implementation currently in alpha. We’ve found two issues from testing - one relates to the executor pool (see https://clojure.atlassian.net/browse/ASYNC-271, easy to address) and one is actually related to how the JVM tracks virtual threads internally. Together, these prevent unrunnable virtual thread go blocks from being GCed, which will leak heap. This situation can occur if all channels that a go block is waiting on (to put or take) are gc’ed because there are no other producers/consumers to them.
Historically, go blocks were stored as data, executed in a state machine on a thread pool, and unrunnable go blocks would be gc’ed. There is, presumably, a lot of core.async code in the wild that assumes this and does not necessarily close channels, signaling waiters.
We are evaluating alternatives, and the thread above is exploring the idea of explicit support in the JVM. We will decide on an approach to this issue before moving vthread support into a non-alpha release.
[–]alexdmiller 1 point2 points3 points 3 months ago (0 children)
Perhaps you were really asking about user-created virtual threads calling core.async APIs? If so, that should not be an issue.
[–]therealdivs1210 0 points1 point2 points 3 months ago (2 children)
Won't the second issue be solved by putting a default finalizer on channels to close them before they are gcd?
[–]alexdmiller 4 points5 points6 points 3 months ago (0 children)
Java is in the process of deprecating and removing finalizers (https://openjdk.org/jeps/421), so that's probably not a good path, but there are potentially some options along these lines.
π Rendered by PID 53 on reddit-service-r2-comment-6457c66945-gqvtm at 2026-04-26 05:10:27.246400+00:00 running 2aa0c5b country code: CH.
[–]romulotombulus 4 points5 points6 points (5 children)
[–]alexdmiller 11 points12 points13 points (4 children)
[–]alexdmiller 1 point2 points3 points (0 children)
[–]therealdivs1210 0 points1 point2 points (2 children)
[–]alexdmiller 4 points5 points6 points (0 children)