Re:Tinyalloc: replacement for malloc/free in unmanaged, line...
by monocasa on Sunday January 06, 2019 @04:01PM
(#18840688)
I don't think he's talking about using malloc "once", he's talking about only using it during init. In practice you end calling it a bunch in that model, the last design I shipped like that ended up making a few hundred malloc (well new operator because this was C++) calls at init.
Under that system malloc/new was just a pointer bump, and an assert if there wasn't enough room. Free wasn't linked, and delete asserted. That heap region (or mine had several heaps that lived in different memory with different characteristics that could be specified with a new overload) is way easier to define in your linker.
Also if the goal is to get one chunk of memory with a single call, why use malloc at all? Why not use the direct memory mapping command?