With Visual C ++, the malloc() function or the new operator ultimately calls HeapAlloc() . If you are debugging the code, you will find that the _heap_alloc_base() function (in the malloc.c file) calls return HeapAlloc(_crtheap, 0, size) , where _crtheap is the global heap created using HeapCreate() .
The HeapAlloc() function does a good job of minimizing memory overhead, while allocating at least 8 bytes. The largest I've seen is 15 bytes per allocation, for allocations from 1 byte to 100,000 bytes. Larger blocks have a large overhead, however, since the percentage of the total allocated resources remains less than 2.5% of the payload.
I cannot comment on performance because I have not tested HeapAlloc() with a custom procedure, however, since the memory overhead when using HeapAlloc() , the overhead is surprisingly low.
Daniel Morin Apr 11 2018-12-12T00: 00Z
source share