Detecting memory leaks in C programs?

后端 未结 5 555
忘了有多久
忘了有多久 2021-01-30 05:33

If we would like to check for memory leaks in a C++ program, we can overload the new and delete operators to keep track of the memory that was allocate

5条回答
  •  隐瞒了意图╮
    2021-01-30 06:19

    Valgrind is what you need.

    I remember reading first chapter of Algorithms in a Nutshell which talked about this although it didn't include code. Just added in case you find it interesting.

    since there is no operator overloading in c can we over-write malloc function point to intercept calls to malloc and track memory allocation

    Actually, you can. GIve LD_PRELOAD a read.

提交回复
热议问题