4 ms·
Caveat emptor, I don't write Zig but followed its development closely for awhile. A core design element of zig is that you shouldn't be stuck with one particula
by IggleSniggle 1y ago
Caveat emptor, I don't write Zig but followed its development closely for awhile. A core design element of zig is that you shouldn't be stuck with one particular memory model. Zig encourages passing an allocator context around, where those allocators conform to a standardized interface. That means you could pass in different allocators with different performance characteristics at runtime.
But yes, there is a default allocator, std.heap.page_allocator
- hansvm 1y agostd.heap.smp_allocator You should basically only use the page allocator if you're writing another allocator.
- SkiFire13 1y ago> you shouldn't be stuck with one particular memory model Nit: an allocator is not a "memory model", and I very much want the memory model to not change under my feet.
- throwawaymaths 1y ago> Zig encourages passing an allocator context around, where those allocators conform to a standardized interface. in libraries. if youre just writing a final product it's totally fine to pick one and use it everywhere. > std.heap.page_allocator strongly disrecommend using this allocator as "default", it will take a trip to kernelland on each allocation.