Compute wave [Datafolder] size in bytes?

When you select a wave in the data browser and elect to display info, you can see a status report on the number of bytes that the selected wave occupies, along with its type, dimension sizes, labels, scaling, etc.

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.
'Redimension Waves' panel will provide helpful infomation.
'Data' menu -> 'Redimension Waves...' invokes it.

Procedure programmer can roughly estimate occupied memory size by following functions.
numpnts(wave)
WaveType(wave)
Understood -- but that's not the actual memory usage attributed to the wave in the Data Browser. There's clearly overhead for dimension labels, scaling factors, etc.

Consider a simple case:

Make/N=1 fp32Wave_1
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.
The Data Browser indeed displays the full size of the wave including the *current* 320 bytes header but it does not account for the wave's note or dimension labels.

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
Variable waveBytes=numpnts(myWave)*sizeOfType(WaveType(myWave))

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.
Hi,

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.
SizeOfType(WaveType(wave)) * numpnts(wave) will give you the number of bytes in the wave regardless of its dimensionality. (SizeOfType is the function shown earlier in this thread.)

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.