Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

How LabVIEW Stores Data in Memory

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

LabVIEW stores data in memory for controls, indicators, wires, and other objects depending on the data type of the object.

Boolean Data

LabVIEW stores Boolean data as 8-bit values. If the value is zero, the Boolean value is FALSE. Any nonzero value represents TRUE.

Byte Integer

Byte integer numbers have an 8-bit format, signed and unsigned.

Word Integer

Word integer numbers have a 16-bit format, signed and unsigned.

Long Integer

Long integer numbers have a 32-bit format, signed and unsigned.

Quad Integer

Quad integer numbers have a 64-bit format, signed and unsigned.

Fixed-Point

Fixed-point numbers have a 64-bit format, signed and unsigned.

Single

Single-precision floating-point numbers have a 32-bit IEEE single-precision format.

Double

Double-precision floating-point numbers have a 64-bit IEEE double-precision format.

Extended

Extended-precision floating-point numbers have an 80-bit IEEE extended-precision format.

Note  In some cases, extended-precision floating-point numbers can have a 64-, 96-, and 128-bit IEEE extended-precision format depending on the computer processor. 80-bit is the most common.

Complex Single

Complex single-precision floating-point numbers consist of real and imaginary values in 32-bit IEEE single-precision format.

Complex Double

Complex double-precision floating-point numbers consist of real and imaginary values in 64-bit IEEE double-precision format.

Complex Extended

Complex extended-precision floating-point numbers consist of real and imaginary values in IEEE extended-precision format.

Extended-precision floating-point numbers have an 80-bit IEEE extended-precision format.

For floating point and complex numbers, s is the sign bit (0 for positive, 1 for negative), exp is the biased exponent (base 2), and mantissa is a number in the [0,1] range.

Time Stamp

LabVIEW stores a time stamp as a cluster of four integers, where the first two signed integers (64 bits) represent the time-zone-independent number of complete seconds that have elapsed since 12:00 a.m., Friday, January 1, 1904, Universal Time [01-01-1904 00:00:00]. The next two unsigned integers (64 bits) represent the fractions of seconds.

Refer to the NI Developer Zone at ni.com for more information about time stamps.

Arrays

LabVIEW stores arrays as handles, or pointers to pointers, that contain the size of each dimension of the array in 32-bit integers followed by the data. If the handle is 0, the array is empty. Because of alignment constraints of certain platforms, a few bytes of padding might follow the dimension size so that the first element of the data is correctly aligned. If you write a shared library that uses a LabVIEW array, you might need to adjust the size of the handle.

The following illustration shows a 1D array of single-precision floating-point numbers. The decimal numbers to the left represent the byte offsets of locations in memory where the array begins.

The following illustration shows a 4D array of 16-bit integers.

In LabVIEW, 1D and 2D arrays are aligned in memory. This aids in performance for linear algebra operations and operations involving the matrix data type.

Strings

LabVIEW stores strings as pointers to a structure that contains a 4-byte length value followed by a 1D array of byte integers (8-bit characters), as shown in the following illustration. If the handle, or the pointer to the structure, is NULL, LabVIEW treats the string as an empty string, which is the same as a string with length value of zero. Because LabVIEW uses the length value and not a terminating character to determine the end of the string, you can embed all characters that include the NULL character, or ASCII character 0, in the string at any point. When passing LabVIEW strings to external code that expects a C string, the embedded NULL characters cause the code to interpret the string as terminating at the first NULL character.

Paths

A LabVIEW path is a pointer to an opaque data structure that contains a path type and path components. The path type is 0 for an absolute path, 1 for a relative path, and 3 for a Universal Naming Convention (UNC) path. A UNC path occurs on Windows only and has \\<machine name>\<share name>\ rather than a drive letter as its first component. Any other value of path type indicates an invalid path.

Use the following functions to access information about a path:

  • FDepth()
  • FDirName()
  • FIsAPath()
  • FIsAPathOfType()
  • FIsEmptyPath()
  • FNamePtr()
  • FVolName()

Use the following functions to add elements to a path:

  • FAddPath()
  • FAppendName()

Use the following functions to create a new path:

  • FNotAPath()
  • FPathCpy()
  • FEmptyPath()
  • FMakePath()
  • FRelPath()

Use the FDestroyPath() function to dispose of a path.

Use the following functions to convert a path to or from a textual form:

  • FFileSystemStringToPath()
  • FPathToFileSystemDSString()
  • FPathToText()
  • FTextToPath()
  • ConvertPathToPlatformIndependentText()
  • ConvertPlatformIndependentTextToPath()

Use the following functions to compare two paths:

  • FPathCmp()
  • FPathCmpLexical()

Clusters

LabVIEW stores cluster elements of varying data types according to the cluster order. You can view and modify the cluster order by right-clicking the cluster border and selecting Reorder Controls In Cluster from the shortcut menu. LabVIEW stores scalar data directly in the cluster, and it stores arrays, strings, and paths indirectly in the cluster. Because of alignment constraints of certain platforms, LabVIEW might add some bytes of padding to the end of a cluster in an array so that the beginning of the next cluster is aligned correctly. If you write a shared library that uses an array of clusters, you must account for this padding if you adjust the size of the handle to the array.

The memory layout of a cluster depends on the platform you are running. LabVIEW may add padding between cluster elements so that those elements are aligned to certain address boundaries. Address boundaries relate to the concept of natural alignment. A piece of data is aligned on its natural boundary if the address at which it begins is a multiple of the size of the data. For example, a 4-byte integer is aligned naturally if it begins at an address which is a multiple of four. Most compilers have an upper limit on this boundary at which the restriction is relaxed. For instance, an 8-byte integer may be aligned on a 4-byte boundary. For the platforms on which LabVIEW runs, the alignment constraints are as follows:

  • (Windows) Data is aligned only to 1-byte boundaries.
  • (Mac OS X and Linux) Data is aligned naturally up to 4-byte boundaries.
  • (VxWorks PowerPC) Data is aligned naturally up to 8-byte boundaries.

On all platforms, clusters adopt the alignment of their most restrictively aligned element.

The following tables represent a cluster that contains a 16-bit integer, an extended-precision floating-point number, an array, and an 8-bit unsigned integer. Each row contains the memory address and its corresponding element and element size.

  • (Windows) Because data is aligned only to 1-byte boundaries, the memory address of the next cluster is 17.

    Memory Address Element Size (bytes)
    0: I16 integer 2
    2: EXT float 10
    12: Handle to Array 4
    16: U8 integer 1
  • (Mac OS X and Linux) Because data is aligned naturally up to 4-byte boundaries, LabVIEW adds 3 bytes of padding after the U8 integer so that the memory address of the next cluster is 24.

    Memory Address Element Size (bytes)
    0: I16 integer 2
    2: Padding 2
    4: EXT float 10
    14: Padding 2
    16: Handle to Array 4
    20: U8 integer 1
    21: Padding 3
  • (VxWorks PowerPC) Because data is aligned naturally up to 8-byte boundaries, LabVIEW adds 3 bytes of padding after the U8 integer so that the memory address of the next cluster is 24.

    Memory Address Element Size (bytes)
    0: I16 integer 2
    2: Padding 6
    8: EXT float 8
    16: Handle to Array 4
    20: U8 integer 1
    21: Padding 3

LabVIEW stores clusters embedded within other clusters directly in line and with no indirection. LabVIEW stores only arrays, strings, and paths indirectly.

The following illustration shows two different clusters that store data the same way.

Waveform

LabVIEW stores waveforms like clusters.

Refnum

LabVIEW stores refnums as signed 32-bit integers.

Variant

LabVIEW stores variants as handles to a LabVIEW internal data structure. Variant data is made up of 4 bytes.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit