Remix.run Logo
▲ cogman10 15 minutes ago

> 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 9 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.