core:mem/virtual
is the package for virtual memory allocators, which is to say that they are allocators which specifically get their memory backing from the operating system’s virtual memory subsystem, who then distribute that memory through the Odin allocator interface.
core:mem.Arena
is an arena allocator, but it does not have any special handling for the memory that backs it. You initialize it with a slice of bytes, and it uses that slice of bytes to place its allocations inside. It does not expand the memory available to it; it merely uses what it is given.
core:mem/virtual.Arena
can optionally expand through the .Growing
variant, initialized with arena_init_growing
, or it can be .Static
, which is similar to core:mem.Arena
but the user does not need to provide memory for it. The .Buffer
type is the one most like core:mem.Arena
, in that the user does provide the memory to back it. In the latter two cases, both have bounded memory; it’s just the source of the memory that changes.
virtual.Arena
is a little fancier, and you can do more with it, but if you know the bounds of the memory you’ll be using and already have the memory allocated from somewhere, then mem.Arena
is the simpler option. I would say most people really only need virtual.Arena
in the case that they have an unbounded memory budget because it has the capacity to add more blocks from virtual memory as demand increases.