Re:Honey, I shrunk {fmt}: bringing binary size to 14k and di...
by jeffbee on Sunday September 01, 2024 @12:24PM
(#41418135)
jemalloc and tcmalloc use size classes, so if you allocate 23 bytes the allocator reserves 32 bytes of space on your behalf. Both of them can find the size class of a pointer with simple manipulation of the pointer itself, not with some global hash table. E.g. in tcmalloc the pointer belongs to a "page" and every pointer on that page has the same size.
[ Parent
| on HN ]
Re:Honey, I shrunk {fmt}: bringing binary size to 14k and di...
by Someone on Sunday September 01, 2024 @02:04PM
(#41418893)
That doesn’t help for C++ if you allocated an array of objects with destructors. It has to know that you allocated 23 objects, so that it can call 23 destructors, not 32 ones, 9 of which on uninitialized memory.
Re:Honey, I shrunk {fmt}: bringing binary size to 14k and di...
by jeffbee on Sunday September 01, 2024 @02:24PM
(#41419044)
I believe the question was more around how the program knows how much memory to deallocate. The compiler generates the destructor calls the same way the compiler generates everything else in the program.