3 ms·
Another option is explicit memory pools when some classes of allocation have well-defined lifetimes. Freeing an entire pool is instant compared to either free(
by benlivengood 6y ago
Another option is explicit memory pools when some classes of allocation have well-defined lifetimes. Freeing an entire pool is instant compared to either free()/delete or GC and produces zero fragmentation.
For example, build parse trees in explicit pools and deallocate the whole tree and associated allocations when done with it.
Language support for this is fairly poor or tricky in OO languages AFAIK; but I'm mostly familiar with C++ where destructors and lack of allocator scoping (until C++11, but optional) make this a pain. The language needs support for formally and transitively abandoning objects (or not caring, like C) to support efficient use of memory pools.