Handles are the better pointers

how I’m doing dynamic memory management in C and C++ these days which basically replaces raw- and smart-pointers with ‘index-handles’. - The Brain Dump / HN

Every sufficiently performance-sensitive system eventually grows some version of a slab allocator 1. There’s really no substitute for packing fixed-sized objects together in N big array chunks. If you can operate in a particular context (or entirely) with N=1, you can substitute handles for pointers. For any reasonable # of objects, those handles can be smaller than a pointer and provide even better compaction and thus cache effectiveness. - HN

Written on April 3, 2021, Last update on April 3, 2021
c++ memory pointer