Valgrind and Python

Michael Hudson mwh at python.net
Tue Jun 10 06:51:24 EDT 2003


Graeme Winter <g.winter at dl.ac.uk> writes:

> Hello Everyone,
> 
> Does anyone know of a simple way to instrument the Python code to
> allow the use of Valgrind? I would like to perform a memory check on
> my extension which uses the python memory allocation, and I guess that
> I am not the first to want to do something like this.

Things that spring to mind: first try a debug build of Python.  This
defines a few smarts that can help catch memory problems.

> I expect that I will also have to change the compilation so that the
> Python allocation won't do anything clever.

If you read the thread "Valgrinding Python" on python-dev from about a
year ago, you may not need to do this.

I'd recommend just running everything under valgrind.  With the hints
from the python-dev thread, you should get no little or no output from
Python itself.

> For those who don't know, Valgrind is a memory checking/debugging tool
> which simulates the running of a i386 machine to do it's work.

Julian Seward (valgrind's author) is one of those people for whom
"fantastically smart" doesn't even come close.

Cheers,
M.

-- 
8. A programming language is low level when its programs require
   attention to the irrelevant.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html




More information about the Python-list mailing list