1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

valgrindをつかってみた

Last updated at Posted at 2016-04-19

環境は CentOS Linux release 7.2.1511 (Core)

インストール

yum search valgrind
yum install valgrind.x86_64

使ってみる

valgrind --leak-check=full hogehoge piyo

hogehogeはチェックしたいプログラム
piyoはプログラムに対する引数

プログラムの終了

Ctrl+Cするか普通に終了するのを待つ

結果

Invalid read of size X

読んではいけないメモリ領域を読んだ時に出る。
メッセージ以下に出てくるのはスタックトレース?

Invalid write of size X

書き込んでは行けないメモリ領域に書き込んだ時に出る

Conditional jump or move depends on uninitialised value

未初期化の変数が条件分岐に使われている

Mismatched free() / delete / delete []

単体でnewしたのにdelete[]してる。もしくは逆
mallocしたのにdeleteしているもしくは逆

X bytes in X blocks are definitely lost in loss record

メモリ確保したのに解放してない

その他

-公式 http://valgrind.org/docs/manual/mc-manual.html
-チェック中は動作が遅くなるので注意

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?