Discussion about this post

User's avatar
Trần Thành Long's avatar

A couple of questions:

1. People usually make a scratch arena locals to a thread using something like __declspec(thread). What if you're on a platform or project that can't use thread-local storage? I usually see people handle this by passing around a "thread context" Care to comment on that?

2. The push and pop operator on the current arena implementation aren't atomic, which mean they aren't thread-safe. How do you go about dealing with memory management for multithreading?

3. Do you think the idea of ArenaTemp can be made more abstract and applied to other kinds of allocators? For example, I may have a generic heap allocator that keeps a free list and allows for out-of-order alloc and free allocations. I can still create an ArenaTemp for this allocator by storing the free list in the ArenaTempBegin and restoring it in the ArenaTempEnd function. The same also goes for a pool allocator, for example. I can still store the current free list and reset it later.

Expand full comment
Samuel Johnson's avatar

Excellent article - it's interesting to me that the greatest pushback for manual memory management (web development) would benefit the most from usage of arenas. The lifetime of a request maps well to the idea of arenas.

Expand full comment
37 more comments...

No posts