struct A {
static std::size_t allocated;
static void* operator new(std::size_t size) {
allocated += size / sizeof(A);
return ::operator new(size);
}
static void* operator new[](std::size_t size) {
allocated += size / sizeof(A);
return ::operator new(size);
}
}
std::size_t A::allocated = 0;
Created
June 3, 2021 21:30
-
-
Save jmftrindade/045d34df3aff88cb956c11890c47cb24 to your computer and use it in GitHub Desktop.
Instrumenting operator new to keep track of mem allocations
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment