Examining C/C++ Heap memory statistics in gdb

后端 未结 2 471
孤城傲影
孤城傲影 2020-12-13 18:56

I\'m trying to investigate the state of the C/C++ heap from within gdb on Linux amd64, is there a nice way to do this?

One approach I\'ve tried is to \"call mallinfo

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 19:22

    If you can change the code:

    #include 
    #include 
    
    void dumpMallinfo(void) {
      struct mallinfo m = mallinfo();
      printf("uordblks = %d\nfordblks = %d\n", m.uordblks, m.fordblks);
    }
    

    In GDB, you can call dumpMallinfo().

提交回复
热议问题