There are two ways to get the actual size (byte) of the IDL variables.
1. Use built-in size function
FUNCTION sizeof, DataItem
;
; First get the information regarding the item
;
Info = SIZE (DataItem)
;
; deduce type and number of elements
;
Type = Info(Info(0)+1)
Nitems = Info(Info(0)+2)
Size = 0
;
; calculate number of bytes depending on item type
;
CASE Type OF
1: Size = 1 * Nitems
2: Size = 2 * Nitems
3: Size = 4 * Nitems
4: Size = 4 * Nitems
5: Size = 8 * Nitems
6: Size = 8 * Nitems
7: Size = 1 * Nitems
8: BEGIN
Tags = TAG_NAMES (DataItem)
Info1 = SIZE (Tags)
FOR j = 0, Info1(Info1(0)+2)-1 DO BEGIN
String = "Size = Size + sizeof(DataItem." + Tags(j) + ")"
ret = EXECUTE (String)
ENDFOR
END
ENDCASE
;
; return size in bytes
;
RETURN, LONG(Size)
END
2. Use the structure information
structure = {variable:variable}
help, structure
The prompt will print out the actual number of bytes that variable occupys.