I've been trying to understand the Roc codebase and one thing I'm having trouble with is understanding how garbage collection is done? I don't see any references in the codebase so I assume that's something Roc's getting in the rust layer some how?
you mean the roc compiler (a rust program) or the output of that compiler (a roc program)
roc program
We use reference counting instead of garbage collection. Richard has probably compared the two in a talk, but I don't think we have that written down somewhere.
That's good to know! Did I miss it in the code?
this a place to start maybe... https://github.com/roc-lang/roc/blob/7b1c009ca2bb07dc10a80136c1dccfc4de9996d2/crates/roc_std/src/storage.rs#L20
I did find a bit of documentation.
I think we most commonly use the term refcount
in the codebase.
Lots of rc
as well.
Thank you, this helps a lot.
Last updated: Jul 06 2025 at 12:14 UTC