[Date Index]
[Thread Index]
[Author Index]
Re: Estimating memory usage of expressions
*To*: mathgroup at smc.vnet.net
*Subject*: [mg109023] Re: Estimating memory usage of expressions
*From*: David Bailey <dave at removedbailey.co.uk>
*Date*: Sat, 10 Apr 2010 06:55:58 -0400 (EDT)
*References*: <hpkgl2$81m$1@smc.vnet.net>
Jim Lambaugh wrote:
> Hi
>
> Is there a way to estimate how many bytes the different expressions in
> Mathematica take from the memory? For example I wish to know how many
> bytes a NxN matrix with real entries is, the list of its eigenvectors,
> eigenvalues etc.
>
> I know of the command "ByteCount", but the results I get are not
> consistent, i.e. a list of 1 integers does not take up the same amount
> of memory as one single integer etc. So: Is there a way to estimate
> these things? I'm running on a 32-bit system (if that makes a
> difference).
>
There are lots of complications here. First of all, lists (vectors and
matrices) can be stored in two formats - packed and unpacked. There are
several functions available in the Developer` context that will test if
a list is packed, and also convert to/from packed format if possible.
Some functions deliver a packed result, but others, such as Import don't
seem to do so - at least in all cases.
Packed and unpacked arrays behave the same way in Mathematica, but
packed arrays are more efficient and use less storage.
A list of one element is not the same as that element itself, and I
would expect the list to require more storage.
As I remember, it is also possible in certain circumstances for
expressions to share storage!
Packed arrays of Real numbers will use 8 bytes per element - possibly
with a small fixed overhead.
Packed integer arrays will require 4 bytes per element, also with a
fixed overhead.
If you want to use packed format, and you presumably do, you need to
ensure that a real array does not contain any integer elements (such as
1 or 0) by using N if necessary before trying to pack the result.
David Bailey
http://www.dbaileyconsultancy.co.uk
Prev by Date:
**Re: if using Mathematica to solve an algebraic problem**
Next by Date:
**Re: if using Mathematica to solve an algebraic problem**
Previous by thread:
**Re: Estimating memory usage of expressions**
Next by thread:
**Re: Estimating memory usage of expressions**
| |