Re: Estimating memory usage of expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg108987] Re: Estimating memory usage of expressions
- From: Nicola Mingotti <nico020978 at gmail.com>
- Date: Fri, 9 Apr 2010 03:32:34 -0400 (EDT)
- References: <hpkgl2$81m$1@smc.vnet.net>
The object "1" and the object "list containing only the element 1" are different in nature so it's expectable they heve different Mathematica representation and different Memory usage. I don't know the C representation for a Mathematica List or a Mathematica Integer, i don't even know if they are public domain. Anyway, if you do ByteCount[{1}] => 56 ByteCount[{1,2}] => 80 ByteCount[{1,2,3}] => 104 ByteCount[{1,2,3,4}] => 128 you see the difference is always 24 bytes. It tried to do a little experiment, the list data structure changes when you add some elements : r = Table[RandomInteger[], {i, 100}]; (ByteCount[r] - 32) / 24 => 100 r = Table[RandomInteger[], {i, 200}]; (ByteCount[r] - 32) / 24 => 200 r = Table[RandomInteger[], {i, 250}]; (ByteCount[r] - 32) /24 => 91/2 !!!! In the last result i would expect naively a result 250, 91/2 tells me that things underwood are more sophisticated. Hope somebody can tell you more ;-) bye n. On 2010-04-08 14:02:42 +0200, Jim Lambaugh said: > 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).