I work on safety critical and realtime c++. We allocate every non-stack byte at startup. If you want something like std::shared_ptr, you provide an allocator that retrieves and replaces memory from a pool. I essentially only use vectors for things like configuration at startup. maps, sets, etc get preallocated.
You can use mimalloc to preallocate a space with MIMALLOC_RESERVE_OS_MEMORY=N and prohibit from requesting more with MIMALLOC_LIMIT_OS_ALLOC env variables or equivalent functions and override malloc/free, new/delete
View all comments
Show parent comment
1
u/johannes1971 Oct 22 '26
Is every byte of memory pre-allocated in that startup buffer? Or are you running your own allocator inside it?