0
1

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.

PythonでValgrindを使う

Last updated at Posted at 2019-11-14

はじめに

メモリリークの検知によく使われるツールとして、Valgrindがある。しかし、Valgrindを使おうとしても、Python 3.5以前では、コンパイルからやり直す必要があった。しかし、Python 3.6以降では、環境変数PYTHONMALLOCでメモリアロケータを変更できるようになった。このため、簡単にメモリリークの調査が出来るようになった。

PYTHONMALLOC=debug ./python membug.py

なお、Valgrindの仕組みは、ダイナミックリンカーの環境変数であるLD_PRELOADをつかって、関数置き換えにより振る舞いを監視する。このため、共有ライブラリの関数の監視なら使うことが出来る。

参考資料

Pydevenv

Valgrind

Python関連

Linux Tools

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?