[Numpy-discussion] [Fwd: Large array using 4 times as much memory as it should]

Fernando Perez fperez.net@gmail....
Thu Oct 30 20:57:25 CDT 2008


On Thu, Oct 30, 2008 at 6:48 PM, Rick Giuly <rgiuly@gmail.com> wrote:
> Please disregard the last message.
>
> I just realised 8*4=32, very sorry about this. Apparently I need some sleep.
>
> -Rick
>
> -------- Original Message --------
> Subject: Large array using 4 times as much memory as it should
> Date: Thu, 30 Oct 2008 18:41:44 -0700
> From: Rick Giuly <rgiuly@gmail.com>
> To: numpy-discussion@scipy.org
>
> Hello All,
>
> I find that python is using about four times as much memory as it should

You may find this handy for looking at your variable's memory use:

In [12]: a = numpy.ones((1024,1024,50), dtype=numpy.uint32)

In [13]: print 'approx size in Mb:',(a.size*a.itemsize)/1e6
approx size in Mb: 209.7152

numpy.who() gives you a nice summary:

In [14]: numpy.who()
Name            Shape                  Bytes            Type
=================================================================

a               1024 x 1024 x 50       209715200        uint32

Upper bound on total bytes  =       209715200


Cheers,

f


More information about the Numpy-discussion mailing list