LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shared variable memory usage

I have a single process shared variable which is an array of doubles.  In a low frequency loop, I have a preallocated array of which I want to write a subset of to the shared variable which I read in another high frequency loop.  If I use the array subset node to get the subset and wire the the subarray output into the shared variable, the Show Buffer Allocations tool shows a black dot on the shared variable indicating that memory is allocated.  If I use the Replace Array Subset node and wire the Shared variable as in the input array, wire the subset in, and then wire the output array to the Shared Variable, the Show Buffer Allocations tool shows no black dots.  Is this correct or is there another way to achieve this.  I thought that with the single process shared variables you are supposed to avoid multiple readers.  In the second scenario, the low frequency loop is "reading" the shared variable to use as the array for which I want to replace a subset of.  However, in the first scenario, the low frequency loop is only writing to the shared variable but it seems like each time its called it will allocate memory.
 
Any thoughts?
 
kmc 
0 Kudos
Message 1 of 2
(2,479 Views)
Hello,
 
This sounds like it could be expected behavior.  LabVIEW has to make decisions about when and where new allocations need to be made, and where buffers can be safely reused.  By using the replace array subset function, the shared variable node may be able to reliably reuse that buffer/array because it knows it's receiving a buffer/array of the same size every time.  In the other case, although you may know that you only extract the same amount of data every time, LabVIEW may not be able to extract that from your code.
 
Perhaps posting a simple example would help clarify things a bit, unless the possibility suggested above makes sense in your case.
 
Best Regards,
 
JLS 
Best,
JLS
Sixclear
0 Kudos
Message 2 of 2
(2,455 Views)