-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Hi @daanx and others!
I was wondering if anyone has ever implemented, or extended mimalloc in ways that it can support tagging - e.g. maybe initially just a custom provided byte, or word, dword that marks the block in a way.
Now I know this comes with few gotchas - existing new/malloc interfaces do not have this, so it has to be a threadlocal "global" (not ideal), but that would be acceptable for our use case. We can have some RAII controlled scopes pushing and popping threadlocal tags.
Then later, through a tracking API we can expose some stats and have IMG1 tag used this amount of bytes, etc.
The nasty bit here, is that this would require reading bits from the header just before that memory block is going to be deallocated... unless some scheme to keep tags on the side.
More or less, something that mimics Microsoft's Kernel ExAllocatePoolXxx functions - https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepool2
Just pondering on ideas, thoughts before diving in.