Home > Back-end >  Are there any tools can record the call tree of each memory allocation in Windows?
Are there any tools can record the call tree of each memory allocation in Windows?

Time:08-04

My project's memory usage has increased after version iteration (it's a multi-thread project). I want to know which part in code is causing the increase.

I think if I can record the call tree for each memory allocation, then I can cluster based on the stack and further identify the code that is causing the memory increase.

The tools should identify caller's dll or lib and record how much memory has been allocated during the entire run of the project.

CodePudding user response:

For memory leak detection in C/C code on Windows please have a look at the UMDH tool which is part of the "Debugging tools for Windows". You'll find many blog posts about how to use it.

CodePudding user response:

I've been using Tracy profiler to track allocations. It requires you to overload the operator new and operator delete though. It comes with a nice visual interface also.

From tracy documentation:

void* operator new(std :: size_t count)
{
  auto ptr = malloc(count);
  TracyAlloc (ptr , count);
  return ptr;
}
void operator delete(void* ptr) noexcept
{
  TracyFree (ptr);
  free(ptr);
}
  • Related