How to get the size of memory pointed by a pointer?
I am currently working on a NUMA machine. I am using numa_free to free my allocated memory. However, unlike free , numa_free needs to know how many bytes are to be freed. Is there any way to know that how many bytes are pointed to by a pointer without tracing it out? There is no way to obtain memory size using underlying API. You must remember size during the allocation somewhere. For Example, You may write your own allocator, that allocates 4 extra bytes, stores in first 4 bytes size of buffer, and during deallocation you can read size of buffer from it: void *my_alloc(size_t size) { void