[melbourne-pug] Python 2.7 memory profiler

Ed Schofield ed at pythoncharmers.com
Mon Apr 18 06:21:50 CEST 2011

Hi David,

On Mon, Apr 18, 2011 at 11:49 AM, David Crisp <david.crisp at gmail.com> wrote:

> Im trying to find a Python 2.7 memory profiler (for windows +64bit
> python) all I can find are the 2.6 versions.
> How do I find out how much physical memory an array is using in memory
> other than doing the calculation of "well this is two bytes and I have
> 1000 of them that means 2000 bytes" ......

I don't know the answer to your first question, but if, by "array", you mean
a NumPy array, you can use the nbytes property:

>>> a = numpy.arange(10**6).reshape(10**4, 10**2)
>>> a.nbytes

The answer is as you said (a.itemsize * a.size). The actual number of bytes
will be a small fixed number of bytes more than the contents (because of the
overhead of the ndarray pointers to dtype etc.), but this is usually


Dr. Edward Schofield
Python Charmers
+61 (0)405 676 229
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20110418/ef95ef20/attachment.html>

More information about the melbourne-pug mailing list