How do I find the memory used by a python process

S

Salim Fadhley

I'm trying to create a python unit-test which will test a complex
program which includes a number of functions which have been
implemented in C or C++.

The unit-test needs to check that after the functions have been run a
few thousand times all of the memory used by those functions has been
un-allocated, i.e. that there are no memory leaks.

I was wondering if there is some way of finding out how much memory
the current thread is using. I would like some kind of simple function
call that gives me the current memory usage of the current process or
thread.

So each test would check the amount of memory available, call the
function N times and then check the amount of memory available
afterwards. If the amount of memory before and after changes by a
certain amount then the test is failed.

All of our unit-tests are single threaded processes. We run Windows
and Python 2.4.

Any suggestions? Thanks!

Sal
 
M

Martin v. Löwis

So each test would check the amount of memory available, call the
function N times and then check the amount of memory available
afterwards. If the amount of memory before and after changes by a
certain amount then the test is failed.

Please take a look at the muppy package:

http://pypi.python.org/pypi/muppy

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top