Profiler > MemoryProfiler

(-g 付きでコンパイル)

$ valgrind --tool=memcheck (プログラム名)

MacOSX

  • valgrind on Mac OS X (10.9) Mavericks
    • http://calvinx.com/2014/05/04/valgrind-on-mac-os-x-10-9-mavericks/
      # Make sure I have autoconf and automake both installed.
      sudo port -v install automake
      sudo port -v install autoconf
      # Grab Frederic's patched valgrind on his "homebrew" branch
      cd ~/work  # My usual project directory
      git clone https://github.com/fredericgermain/valgrind/ -b homebrew
      cd valgrind
      # Because he placed VEX as a git submodule, we have to make sure we clone it too
      git submodule init
      git submodule update
      # With VEX submodule now available, we can compile valgrind
      ./autogen.sh
      ./configure
      make
      # sudo make install
      make install

.

  • valgrindの使い方
    • http://kzk9.net/column/valgrind.html (webarchive)

      valgrind --leak-check=full command

      • --tool=cachegrind(キャッシュミス率を測定)
        • cg_annotate(ボトルネックになっている部分を探す)
      • --tool=massif(ヒーププロファイリングを行いメモリ使用量をPostScript形式で可視化)
      • --track-fds=yes(ファイルディスクリプタの閉じ忘れを検出)
      • --trace-children=yes(子プロセスまでトレース)等

関連