Hello,
I am working on a trace tool for multithread applications, more especially about memory allocation.
I would like a per thread memory allocation. I know that when a thread do a malloc, the memory used is the global heap. I would like to trace which thread allocated how much memory.
I did a wrapper upon malloc, incrementing values each time there is a malloc as:
void *mymalloc(size_t size) {
mem_used[thread_id] += size;
return malloc(size);
}
It works well. The problem is with free
method, which does not return how much memory is released.
Don't take into account my solution, it is just to show what I tried.
EDIT:
As mentionned above, keeping my own table is a too heavy method.