GHC’s RTS options for garbage collection

Generally speaking, garbage collection is a space/time tradeoff. Give the GC more space, and it will take less time. There are (many) other factors in play, cache in particular, but the space/time tradeoff is the most important one. The tradeoff works like this: the program allocates memory until it reaches some limit (decided by the … Read more

Why doesn’t this thread pool get garbage collected?

This doesn’t really have anything to do with GC being non-deterministic, although it doesn’t help! (That is one cause in your example, but even if we ‘fixed’ it to eat up memory and force a collection, it still wouldn’t finalize) The Worker threads that the executor creates are inner classes that have a reference back … Read more

Circular references in Javascript / Garbage collector

Any half-decent garbage collector will handle cycles. Cycles are only a problem if you do naive reference counting. Most garbage collectors don’t do ref-counting (both because it can’t handle cycles, and because it’s inefficient). Instead, they simply follow every reference they can find, starting from “roots” (typically globals and stack-based variables), and mark everything they … Read more