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.

flip's avatar

This concept is new to me, so I'm not sure I quite understand it's usage very well.

How is the usage of a pool allocator any different from a general purpose heap allocator? The lifetimes of the (in this case) entities can be arbitrarily different, so the "stack" way of thinking doesn't seem to hold. The example also doesn't seem to care about a specific scope for each group of objects, as it's done over the global game state (or do you expect to reset the game state several times, therefore gaining the benefit of just popping everything from the "permanent" arena?)

Thanks for the article

48 more comments...

No posts

Ready for more?