[SciPy-dev] Reliable way to know memory consumption of functions/scripts/etc..

Francesc Altet faltet@carabos....
Wed Jun 13 04:15:11 CDT 2007

El dt 12 de 06 del 2007 a les 15:27 +0900, en/na David Cournapeau va
> Hi,
> I was wondering whether there was a simple and reliable way to know how 
> much memory a python script takes between some code boundaries. I don't 
> need a really precise thing, but more something like how does a given 
> code scale given its input: does it take the same amount, several times 
> the same amount, etc... Is this possible in python ?

I don't think this is going to be possible in plain python (in a
non-debugging version of python at least).  What I normally do is
'spying' in real time the process through the 'top' command and infer
the increment of memory usage doing some experiments sequentially.
There should be better tools around, though.

Incidentally, I've some code that gives you the amount of memory that is
currently being used by the process in some point of the code, but this
is different from knowing the amount of memory taken between two points.
If you are interested on this, tell me (only works on linux, but it
should be feasible to port it to win).


Francesc Altet    |  Be careful about using the following code --
Carabos Coop. V.  |  I've only proven that it works, 
www.carabos.com   |  I haven't tested it. -- Donald Knuth

More information about the Scipy-dev mailing list