memory leak debug

前端 未结 6 1571
臣服心动
臣服心动 2021-02-15 04:17

What are some techniques in detecting/debugging memory leak if you don\'t have trace tools?

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-15 04:46

    Similar questions on SO:

    • Memory leak detectors for C
    • Strategies For Tracking Down Memory Leaks When You’ve Done Everything Wrong

    In addition to the manual inspection techniques mentioned by others, you should consider a code analysis tool such as valgrind.

    Introduction from their site:

    Valgrind is an award-winning instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

    The Valgrind distribution currently includes six production-quality tools: a memory error detector, two thread error detectors, a cache and branch-prediction profiler, a call-graph generating cache profiler, and a heap profiler. It also includes two experimental tools: a heap/stack/global array overrun detector, and a SimPoint basic block vector generator. It runs on the following platforms: X86/Linux, AMD64/Linux, PPC32/Linux, PPC64/Linux, and X86/Darwin (Mac OS X).

提交回复
热议问题