3 ms·
> by encoding it into the returned pointer More accurately speaking though, this information is not directly available from the pointer (unless we have a unive
by lifthrasiir 3y ago
> by encoding it into the returned pointer
More accurately speaking though, this information is not directly available from the pointer (unless we have a universal pointer tagging support today...) and should be mapped via the allocator internal data structure. This is what o11c referred by "arenas/buckets/whatever", and having a size information does simplify this process.
The metadata around the allocation is comparably expensive especially for smaller allocations anyway, so modern allocators would have at least two classes of memory depending on the size. So even when the allocator doesn't make use of any other size information, it is possible that the size information can still be helpful.
- saagarjha 3y agoHaving the size is definitely useful, because you can skip the metadata. But since needing this information in some form or the other is very important it is generally easy to derive-no walks or anything, because that would be slow.
- jaywee 3y agoIt can be - the allocator just needs to mmap() different bucket pools to different base addresses.