Navigation:  ThinBASIC Language > Data types and variables > TYPE (ord UDT User Defined Types) > UDT (User Defined Types) > Memory representation >

Size

Previous pageReturn to chapter overviewNext page

 

Size

 

In order to determine the size of UDT in memory, alway use dedicated functions.

 

SizeOf will tell you how much memory is occupied by UDT. You can use it both with UDT or UDT variable:

 

msgBox SizeOf(Point2D)
 
DIM point AS Point2D
 
msgBox SizeOf(point)

 

Both of these will return 8 in this case, because UDT has two single precision members, each occupying 4 bytes.

 

How can you get this detailed information for members? Use SizeOf directly on them:

 

 

msgBox strFormat$("Size of .x is: {1} bytes, .y {2} bytes",
                  SizeOf(point.x),
                  SizeOf(point.y))

 

Please note the dynamic STRING always occupies 4 bytes, because it is internally represented via pointer.