Losing Elements from LabVIEW Queue

Updated Sep 2, 2022

Reported In

Software

  • LabVIEW

Issue Details

I am using a queue to transfer data between my producer loop and consumer loop.  I see that my acquisition loop writes X items to the queue, but less than X items are saved to disk.  Sometimes more elements in my queue are dropped than at other times.  Why are these elements in my queue being lost, dropped, or disappearing before they are being read and processed?

Solution

There are many potential reasons for this behavior.  Below are potential causes that you will want to look out for and possible solutions:
  • Queue being destroyed after the acquisition loop completes, but before the write loop completes all writes.  Elements left in the queue are lost. 
    • You can get past this by merging errors from both loops to make sure both complete before destroying the queue.  If the write loop is always slower, then you can also choose to destroy the queue after the write loop completes.
    • You can also use Channel Wires  to stream the data between your two loops and then stop them when the last element is written to the queue using the last element? parameter.  You can also look at Stopping Parallel While Loops in LabVIEW with One Stop Button  for a more in depth discussion of ways to stop parallel loops, such as your producer and consumer loop.
  • Queue has multiple readers.  If there are multiple loops reading from the queue, the loop that writes to disk may not be reading in all the elements on the queue. 
    • You may want to consider using Channel Wires  and replicate the channel if you have multiple readers that all need to read in all the information.