Is there a command I can invoke to print malloc data structures?

Hey. I wonder if there is any ready-made function that I can call to print all the malloc data structures so that I can see which memory is allocated for which variable?

I have this memory corruption that when I free one variable, it complains, but I don’t know which variable is adjacent to it.

Thank!

+3
source share
4 answers

Try running the program under valgrind. If you're lucky, this will point you directly to the offensive memory record. (If you're out of luck, you'll just get a stream of false code complaints in the back of C library.)

+3

, , , , .

, , , , .

, gdb, . , , , , .

, , , , .

0

, , . https://github.com/cloudburst/libheap Win32 windbg "! Heap".

0

CheckPointer , .

- "" , . , ; , , . , Valgrind , , . CheckPointer .

CheckPointer (, , ) . , , (, , ). .

CheckPointer will also provide a dump after executing all the storages stored in memory; Of course, you could call this dump procedure at any place in your code as an aid.

0
source

Source: https://habr.com/ru/post/1779760/


All Articles