LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Any way to pass data in a shift register by reference?

I am trying to follow good memory handling practices in LabVIEW, so I have stored my large data arrays in a shift register for use as a circular buffer in a queued state machine. I then use Replace Array Subset to insert new data into the shift register at the correct position to implement the circular buffer. However, when I call a sub-VI to write this data to disk, LabVIEW runs of memory ("Memory is Full" error) because it allocates a copy of the shift register data to pass to the sub-VI. Is there any way to pass a reference to the data stored in the shift register, and avoid making the copy? Thanks in advance for your help! Tom
0 Kudos
Message 1 of 5
(3,750 Views)

Please review the "Clear as Mud" thread where Greg McKaskle explained how the structure of sub-VI's can make it possible to a sub-VI and let it work in the buffer of the caller.

 

A modern approach can take advantage of the DVR (data value reference) to hold data in a single buffer and access same from numerious callers.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 5
(3,743 Views)

If you're doing this right, passing data from a shift register to a subVI should not require a copy unless the subVI modifies the data.  Are you converting the entire large array to some other format, for example using array to spreadsheet string?  If so, you might need to process the array and write to disk in smaller chunks.  Another possibility is saving the data in a functional global variable, then make one of the functions provided by that VI "Write to Disk" so that it has direct access to the data.  I think you can make it work without doing that, though.  Can you share the VI that writes the array to disk?

0 Kudos
Message 3 of 5
(3,715 Views)

First make sure that the front panel of the subVI is not loaded (This will happen if you have the front panel open or if it contains property nodes, for example).

 

If you have LabVIEW 2010, you can also inline the subVI.

 

Can you show us some code? I am especially interested in the subVI. How big is your data?

0 Kudos
Message 4 of 5
(3,696 Views)

Thanks, guys, for your help! Between all the clues you gave me, I was able to figure out what the problem was. It turned out that the control and indicator for the data were contained within a wrapping case structure to deal with any incoming errors. Once the control and indicator were moved outside the case structure (so the data would pass straight through regardless of error condition), the buffer allocation tool indicates that the array copy has been eliminated.  Thanks again!

 

Tom

 

0 Kudos
Message 5 of 5
(3,668 Views)