Currently we use dedicated malloc spaces (i.e. headers) to tag memory pointers with our own data (i.e. mem_tags)
When we count allocations we use requested bytes count, but it looks like the more accurate way is to use malloc_size(), which, according to man page "returns the size of the memory block that backs the allocation pointed to by ptr". However, this would require us to track memory pointers, which we are not doing.
There are advantages to using hashtables here instead:
- no need for pre-init cache
- we can turn NMT ON/OFF during runtime
- accurate memory report (can only be guarantted at the time of the report)
- no unnacnticipated memory overhead (wastage due to native os allocating more byte than requested)
When we count allocations we use requested bytes count, but it looks like the more accurate way is to use malloc_size(), which, according to man page "returns the size of the memory block that backs the allocation pointed to by ptr". However, this would require us to track memory pointers, which we are not doing.
There are advantages to using hashtables here instead:
- no need for pre-init cache
- we can turn NMT ON/OFF during runtime
- accurate memory report (can only be guarantted at the time of the report)
- no unnacnticipated memory overhead (wastage due to native os allocating more byte than requested)