dynamic-arena

Crates.iodynamic-arena
lib.rsdynamic-arena
version0.1.6
sourcesrc
created_at2017-11-04 16:52:51.367815
updated_at2022-02-14 00:49:05.436211
descriptionDynamically typed arenas, supporting any `Sized` type.
homepage
repositoryhttps://github.com/Techcable/rust-dynamic-arena
max_upload_size
id38144
size20,128
(Techcable)

documentation

https://docs.rs/dynamic-arena

README

dynamic-arena crates.io docs.rs

Dynamically typed arenas, supporting any Sized type.

Features

  • 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::Arenas, you can use one DynamicArena
    • 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

Disadvantages

  • 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
Commit count: 10

cargo fmt