Remix.run Logo
▲ Johanx64 2 hours ago

Arenas, etc is GC done right.

Or rather GC done explicit.

You control when and where and how garbage gets collected in various buckets and disposed off.

Without the performance hit of fully automatic GC.

> Risking memory leaks is crazy when it's not something the customer is demanding.

Memory leaks have NEVER been a significant source of bugs.

Memory corruption has always been the problem (lack of memory safety, ie. operating in perpetual unsafe block), not the memory leaks.

Memory leaks are relatively trivial to track and account for in comparison.

▲pron 26 minutes ago | parent | next [-]

Generational moving GCs work much like arenas, and they work without the limitations of arenas and without the performance hit of malloc/free. That's not to say arenas aren't very efficient and useful, but few languages make them convenient and composable enough (Zig), and even then they need to be used with care.

▲cogman10 15 minutes ago | parent [-]

> and without the performance hit of malloc/free.

Arenas avoid most of the performance problems of malloc/free.

I think the bigger problem with arenas and manual management is memory lifetime is very hard to get right, particularly in the context of concurrent operations. It also cuts away algorithms you can do.

▲pron 8 minutes ago | parent [-]

> Arenas avoid most of the performance problems of malloc/free.

Sure, but they're not fully general, which is why you also need malloc/free for things that don't work well in arenas (or write the equivalent of malloc/free on top of arenas, which is what you need to do in Goose: https://github.com/aardappel/goose/blob/master/bench/kostya/...).

Also, arenas can be an even better fit for languages with good GCs than languages without a GC.

▲cogman10 2 minutes ago | parent [-]

> arenas can be an even better fit for languages with good GCs than languages without a GC.

That's counterintuitive to me. I could see them being useful if you need off heap allocations, but on the heap it seems like they'd tend to be harmful rather than helpful. The only benefit they'd seem to have is forcing the colocation of memory. But they have the big downside of (likely) ending up promoting a bunch of memory into old gen.

▲jeremyjh 2 hours ago | parent | prev [-]

[dead]