LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone tell me if there is reason for this array to reinitialize to another location in memory?

It will stick... that's why I initialize it outside the while loop, so I use the same array over and over.  I've been doing this for years and it works.  I just want to know if there is something in the code that might make LabVIEW make a new copy and put it elsewhere.

0 Kudos
Message 21 of 45
(902 Views)

I guess I don't know your definition of "stick". 😄

Where is "elsewhere" and how do you tell?

 

0 Kudos
Message 22 of 45
(900 Views)

By stick I mean the array is defined in memory and always stays where it was originally defined.  Elsewhere would be anywhere other than where it was originally defined.  How can I tell?  That's my question.  I mean, when it works I can tell that it's staying put.  This, however, is not working, and so I'd like to know if there is a way to test where it is stored in memory from one iteration to the next.

0 Kudos
Message 23 of 45
(896 Views)

If you want to start with a blank array with each iteration of the loop, do what you currently do. If you want to retain the updated values, the array needs to be kept in a shift register.

0 Kudos
Message 24 of 45
(889 Views)

Won't that force copies to be made in my sub vi because I'd then have to use an output array?

0 Kudos
Message 25 of 45
(884 Views)

@rickford66 wrote:

By stick I mean the array is defined in memory and always stays where it was originally defined.  Elsewhere would be anywhere other than where it was originally defined.  How can I tell?  That's my question.  I mean, when it works I can tell that it's staying put.  This, however, is not working, and so I'd like to know if there is a way to test where it is stored in memory from one iteration to the next.



I don't think there is a way for you to tell where LabVIEW stores the array in memory. One of the features of LabVIEW that I really appreciate is that I don't have to worry about the low level things such as memory allocations that I do have to worry about when writing C.

 

The only thing I can think of where LabVIEW would move a an array to a different location is if you add something and it requires a new allocation because the current one is too small.

 

Why does it matter where the array is?

=====================
LabVIEW 2012


0 Kudos
Message 26 of 45
(888 Views)

It doesn't matter where it is.  I just don't want to be making copies over and over.  I want to, if possible, use the same array over and over and only replace one element per iteration.  Creating a new array and copying over the contents takes time.

0 Kudos
Message 27 of 45
(885 Views)

If you put it in a shift regsiter, it is kept in exactly one location. You can read from that location on the left, modify the array, then write the changed value back on the right.

0 Kudos
Message 28 of 45
(875 Views)

Another good candidate for a shift register is the rate index. You can also use a feedback node if those existed in LabVIEW 7.0.

=====================
LabVIEW 2012


0 Kudos
Message 29 of 45
(872 Views)

7.0 has feedback nodes.

I see that a shift register would work if I was modifying it directly, but I'm passing it to a sub vi.  In the calling vi, I would initialize the shift register.  I would pass the left side shift register to the input of the sub vi and pass the output of the sub vi to the right side of the shift register in the calling vi.  Here's my question...   If I use an array variable as the input to the sub vi (as it is now) and put the modifed array into another array variable as the output from the sub vi, will, inside the sub vi, the input and output array be the same array as the shift register, or will it all be copies?  Thanks.

 

0 Kudos
Message 30 of 45
(869 Views)