Dynamically typed arenas, supporting any Sized
type.
- Arena allocation is very fast, just requiring a pointer-bump in the common case
- You can statically guarantee the pointers will live as long as the arena
- Unfortunately this means the arena's memory can only be freed all at once
- Allows creating self referential arena-allocated structs
- Instead of using multiple
typed_arena::Arena
s, you can use oneDynamicArena
- This helps reason about your code and significantly reduce memory usage
- Since all the memory is contiguous, it could even help improve cache performance.
- Compiles on latest stable
- Slightly slower allocation than a
typed_arena::Arena
for non-Copy
types- This is because dropping is dynamically dispatched
- In order to maintain safety, all pointers in the allocated items must live at longer as long as the arena itself, so that the items do not outlive the items they point to.
- This statically prevents using self-referential structs with
alloc
- However, you can still use them with
alloc_copy
- See the safety section of the docs for more info on how to use this