LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global array vs global array reference

Is it advantageous from an internal memory-management perspective to use a global reference to a large array on the FP of the main VI, versus making the array a global itself and accessing it directly?
0 Kudos
Message 1 of 4
(2,672 Views)
No. Both ways are inefficient.

In both cases, when you read the array (global access or value property) the whole array get copied.

The best way is to store your large array in the shift register of a LV2 global VI and always operate on the array within this VI. See the VI I attached in this thread.


LabVIEW, C'est LabVIEW

Message 2 of 4
(2,672 Views)
I have read through the thread you posted a link to (plus I've also read other info). I understand the concept of LV2 globals and why they're beneficial for avoiding race conditions. While you answered my question by noting that both methods are innefficient due to copying the entire array, isn't a buffer generated also if you read an array stored in a subVI? Don't you just get a copy of that array too if you use a LV2-style global? And if that's the case, how is the array copying different when compared to a regular global or property node?
0 Kudos
Message 3 of 4
(2,672 Views)
Of course if you read the whole array from the LV2 Global output, it will be copied if you attempt to modify it. To reduce copies, any manipulation to the array have to be done inside a case of the LV2 Global. LabVIEW is very efficient to reuse memory from/to shift registers. An operation like Replace Array Element/Subset will be done "in place", without copying the array. If you extract some elements (index, array subset), only these elements are copied for output. Some other operations that resizes the array require the memory to be reallocated and the array to be copied.


LabVIEW, C'est LabVIEW

Message 4 of 4
(2,672 Views)