Discussion:
Valgrind and Python
Oren Tirosh
2003-05-28 12:52:45 UTC
Permalink
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.
I expect that I will also have to change the compilation so that the
Python allocation won't do anything clever.
On Unix/Linux you can build a Python interpreter that uses the default
system malloc using

./configure --without-pymalloc

I don't know the Windows equivalent.

Oren
Graeme Winter
2003-05-28 11:01:24 UTC
Permalink
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.

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

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.

Cheers,

Graeme
Jack Diederich
2003-05-28 12:12:45 UTC
Permalink
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.
I expect that I will also have to change the compilation so that the
Python allocation won't do anything clever.
An easy low tech solution I've used is to make a special build that #defines
allocations to use the normal system malloc/free and compile the extension
with electric fence (similar purpose to valgrind).

-jackdied
Michael Hudson
2003-06-10 10:51:24 UTC
Permalink
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
Continue reading on narkive:
Loading...