mimalloc
mimalloc copied to clipboard
Debug memory allocation
Hi, I would like to debug memory allocations at runtime. Is there some kind of callback we can provide to instrumentalize our code ? Something like:
// Starting from here, memory allocations are not allowed
mi_set_option(mi_option_enable_allocations, 0);
auto* p = malloc(100); /// --> calls abort() or throws an exception
void on_alloc() {
std::print("Allocations detected !");
}
// Setup a callback for anything allocation related
mi_set_callback(&on_alloc);
auto* p = malloc(100); /// --> calls on_alloc()
Thanks for your help !
@daanx any thoughts ?
Fixed with the new realtime sanitizer in clang 20 👍