4 ms·
Haskell does, https://wiki.haskell.org/GHC/Memory_Management https://wiki.haskell.org/GHC/Memory_Management
by __s 5y ago
Haskell does, https://wiki.haskell.org/GHC/Memory_Management https://wiki.haskell.org/GHC/Memory_Management
- WJW 5y agoI'm pretty sure that Haskell supports cyclic data structures and that GHC garbage collection is more complicated than that. See for example the presentation by Ben Gamari over here: https://www.youtube.com/watch?v=EQqBpVRA3wU https://www.youtube.com/watch?v=EQqBpVRA3wU. Haskell GC is a generational copying design. Optionally you can enable the low-latency GC in newer runtimes, which is still generational and copying for the youngest generation but uses a parallel mark-and-sweep algorithm for the later generations.
- __s 5y agoPotentially cyclic values are statically known But yes, GCs have evolved in the past decade, so these things are subject to change
- kmill 5y agoThat page is incorrect about GHC's memory management -- I verified this with a question to haskell-cafe around 2014, and I guess no one got around to updating it. The linked paper at the bottom of the article explains how things work and have worked for a long time now. The source of cyclic references, and even references from old to new generations, comes from "thunks" (unevaluated lazy computations). Haskell guarantees that a thunk only ever gets evaluated once, and the way this is implemented is that the thunk is mutated with a pointer to the evaluation result. So the garbage collector needs to deal with mutations, cyclic references, and references from old to new generations. (All that in a language with supposedly immutable data!)