Compute wave [Datafolder] size in bytes?
kravlor
Is there a built-in Igor function which can return the size in bytes of the wave? (I seem to be missing it if there is...)
I'd like to use such a capability to help my users find and kill large memory-consuming waves and/or data folders.
Thanks in advance for any help.
'Data' menu -> 'Redimension Waves...' invokes it.
Procedure programmer can roughly estimate occupied memory size by following functions.
numpnts(wave)
WaveType(wave)
October 28, 2010 at 11:31 pm - Permalink
Consider a simple case:
Make/N=2 fp32Wave_2
Make/N=1/I int16Wave_1
The resulting sizes are 324, 328, and 322 bytes, respectively.
It seems like there's approximately 320 bytes of header information, followed by the number of bytes one would expect given sizeof({fp32,i16}) * numpnts(). I haven't played around with it further, but what I'm getting at is whether there's an official method to get at the data accessible in the UI, be it the Data Browser or the Redimension dialog. Igor's typically very, very good about this, which lends me to believe I'm missing something somewhere.
October 29, 2010 at 07:38 am - Permalink
It seems to me that for your application the exact size of the header is irrelevant, in other words, large waves can be selected based on the product of number of points in the wave and the size of the wave's number type:
with
Function sizeOfType(inType)
Variable inType
Variable size=1
if(inType & 0x01)
size*=2
endif
if(inType & 0x02)
size*=4
elseif(inType & 0x04)
size*=8
elseif(inType & 0x10)
size*=2
elseif(inType & 0x20)
size*=4
elseif(inType==0)
size=nan
endif
return size
End
Note that the last function is not going to work for text waves, DFRef waves and other abnormalities.
Granted, this is not going to count dimension labels etc., but all that is rather small compared to wave data. The only component that can get rather large is the wave note, which you can obtain via the Note operation and then use strlen() to obtain its size.
A.G.
WaveMetrics, Inc.
October 29, 2010 at 09:38 am - Permalink
I need to find what is causing my experiments to swell and would very much like to simply access the size function. The above code while a good start still needs to understand and anticipate multidimensional waves. I see a code snippet that addresses part of need (http://www.igorexchange.com/node/1674), but it also is only looking for one dimensional waves.
Perhaps it is a wish list item. But a SizeOfObject function would be useful.
December 18, 2010 at 01:29 pm - Permalink
numpnts returns the total number of points in the wave regardless of its dimensionality. For example, it will return 6 for a 3x2 matrix wave.
The FindBigWaves function that you referenced uses numpnts and therefore will work on waves of any dimension.
December 18, 2010 at 06:18 pm - Permalink
December 22, 2010 at 08:39 am - Permalink