&gt; The C++ equivalent would be to allocate as much as possible on the stack, and then make sure to do a restart every night to eliminate any heap fragmentation that is left.<p>I think that&#x27;s a very brute-force approach. You could instead use an actual allocator which behaves the way you want.<p>For example this is how arena can work without any restart&#x2F;stack magic: <a href="https:&#x2F;&#x2F;github.com&#x2F;cleeus&#x2F;obstack&#x2F;blob&#x2F;master&#x2F;arena_test.cpp#L186" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cleeus&#x2F;obstack&#x2F;blob&#x2F;master&#x2F;arena_test.cpp...</a><p>Same happens in google&#x27;s protobufs <a href="https:&#x2F;&#x2F;developers.google.com&#x2F;protocol-buffers&#x2F;docs&#x2F;reference&#x2F;arenas" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;protocol-buffers&#x2F;docs&#x2F;referenc...</a><p>There&#x27;s no need (almost) for manually wiping heaps at system level if your language allows you to change the allocator at any point of the app.