This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

TDMS Write Memory Growth

Updated Dec 18, 2023

Reported In

Software

  • LabVIEW Full
  • LabVIEW Professional
  • LabVIEW Base

Issue Details

My memory (RAM) usage grows slightly each time the TDMS Write VI executes. Is this a memory leak, and how do I prevent memory usage from increasing?

Solution

There are a few possible solutions to the issue:
  1. It is possible that the references of the TDMS file are not closed appropiately. For every Open TDMS function you should close the reference using the TDMS Close function. 
  2. If you are using the standard TDMS APIs to write data to multiple channels at a time, you must write the same number of data values to these channels in the same order.
  3. Set the NI_MinimumBufferSize property on channels before logging to the TDMS file. An example of setting this property is attached as Minimum Buffer Size Example.vi. This should decrease the speed of memory growth. Refer to the LabVIEW Help for more detailed information.
  4. If you are logging data continuously for an extended time, National Instruments recommends that you split the logging session into multiple shorter sessions. For example, you can write the data to multiple TDMS files by logging the data to a new TDMS file every hour. Using shorter logging sessions can help reduce the memory growth.
  5. After the whole logging session completes, you can defragment each TDMS file and then combine them into one large file. 
  6. Upgrading the TDMS component to the latest version can mitigate memory growth but does not completely eliminate this issue.

Additional Information

With the standard TDMS API, the TDMS Open VI opens the TDMS file for reading and writing. As you write data to your TDMS file, the TDMS API keeps a cache in memory that makes it easier to randomly access data within the file.  If you have an application that continually logs data to disk using TDMS, this may present as a memory leak.