Solution
These error messages are typically encountered when developing an application with large data sets of arrays, clusters, or waveforms. As LabVIEW stores each data set in a contiguous block of memory, the block of memory available on your computer might not be large enough to store a large data set.
Another reason could be that a lot of references are being opened and not closed properly. Closing unused references is very important in LabVIEW and if not managed properly, it can result in memory leaks.
Below are some suggestions to help prevent this error message from appearing:
Reducing Memory Used by Arrays, Clusters, and Waveforms
- If you have an array with a large data set, if possible, use a smaller data type to represent the items in the array. For example, if the items in the array are represented with double-precision floating-point numbers (DBL), but the range of possible expected values is limited to integers between 0 and 100, you can change the integer representation of the items in the array to unsigned 8-bit integers (U8). The U8 numeric data type uses an eighth of the memory that the DBL data type uses.
- In LabVIEW 8.5 and later, use the In Place Element Structure to avoid making copies of data when using an array, cluster, or waveform.
- If you are graphing data from a large array, use max-min decimation to avoid graphing every data point. For more details on this technique, visit the Displaying Large Data Sets section of the Memory Management for Large Data Sets LabVIEW documentation.
- Use the Profile Performance and Memory tool to help narrow down and identify which VIs are responsible for the memory usage .
- Analyze the large data set to determine where memory is full. Stream or write the data to disk and use a high-performance analysis and reporting tool, such as TDMS files and NI DIAdem software.
Reducing Memory Usage in Applications
- To limit the number of times LabVIEW copies data, reduce the number of global and local variables in your application. Instead of using variables, consider using a producer/consumer design pattern or the New Data Value Reference function to create a reference to the data.
- Separate large sections of code into subVIs and use the Call By Reference Node to call the subVIs dynamically. A subVI is not in memory until a VI calls it dynamically.
- Set large subVIs to non-reentrant when possible. Non-reentrant is the default setting for Windows and Real-Time VIs.
- Use the NI LabVIEW Desktop Execution Trace Toolkit to identify problems that could negatively impact performance, such as memory leaks and reference leaks. The toolkit can also collect low-level information such as call chain, thread ID, and location in virtual memory of trace, as well as profile VIs, executables, and shared libraries.
- Reduce the polling rate of your front panel objects. If you are refreshing waveform graphs as quickly as possible, this could use a lot of memory. Reduce the polling rate to a user acceptable number.
Increasing Memory in LabVIEW
- Increase the amount of virtual memory of the system.
- Note that the amount of memory LabVIEW can allocate depends on the bitness of the LabVIEW software and operating system used.
- Consider using LabVIEW 64-bit, which allows for more memory usage but does not support all of the modules, toolkits, and drivers that LabVIEW 32-bit does. This and other differences are outlined in the LabVIEW 32-Bit vs. 64-Bit Applications FAQ. If the 32-bit version of LabVIEW is required for specific drivers/ toolkits, consider integrating both versions and using the 32-bit version only for the drivers/toolkits calls and the 64-bit version for the rest of the application. Use Network Protocols to communicate between 64-bit and 32-bit applications.
Closing References in LabVIEW
- When you open a reference to an application, project, VI, or other reference source, LabVIEW allocates memory to store that reference. To free up the space in memory where LabVIEW stored the reference source, you must close the reference. For more information, you can read more information on Closing References in LabVIEW.
- When a shared re-entrant VI is called dynamically, a new clone instance is created and the instances are not re-used. Therefore, the references need to be closed properly.
Clearing Instruments Tasks
- When using an Instrument Driver like DAQmx, ensure that you clear tasks within a loop. For example, using the DAQmx Create Task VI inside a loop without including a DAQmx Clear Task VI can result in an undefined number of channels being created, which may cause memory usage to increase in the VI.