C++ already gives us a tool for pointer zapping
C++ already gives us a tool for pointer zapping
Posted Oct 18, 2024 18:05 UTC (Fri) by Wol (subscriber, #4433)In reply to: C++ already gives us a tool for pointer zapping by notriddle
Parent article: Zapping pointers out of thin air
It would be a bit more work for the programmer, but this sounds like it would be easily possible with arena allocs.
I understand behind the scenes malloc allocates a big area, which it hands out in small bits. If that big area is an entry in the page table, and especially if the programmer can hint to malloc that "these are long lived, these are short lived, these are small, these are large", it's then easy to move/consolidate all this in ram (copy, update the page table, you're done), and malloc can just drop the arena and not re-use the arena's logical address when it's all freed.
Cheers,
Wol