10-17-2009 08:27 PM
10-17-2009 10:13 PM
Garvacious wrote:In other words, is there a need to overcomplicate things by coding something like the bottom loop?
No, the top example is perfectly fine. The compiler can figure out all final array sizes at compile time and allocate memory accordingly. The same buffers are re-used across all iterations.
10-18-2009 03:41 AM
altenbach wrote:No, the top example is perfectly fine. The compiler can figure out all final array sizes at compile time and allocate memory accordingly. The same buffers are re-used across all iterations.
Yes, when working with constants. But what if the data to insert in the array comes from a DAQ card or from a calculation or from a TCP connection (string type-casted to array of DBL)? Then LV doesn't necessarily know the array size (even if it is constant).
Will it try to reuse the array if it fits and only allocate memory if the size would be larger than in the previous iteration?
10-22-2009 11:28 AM
Thanks for all the response- I think Altenbach's last answer sums it up pretty well. (I am assuming he was not making the assumption of having constants always populating the array).
I guess it was one of those old LabVIEW 101 misconceptions I carried around for years- "never use Build Array in a loop". Of course I violated that rule all the time, but now I know for sure that it is not using the Build Array function that causes inefficient use of memory, but specifically changing the array's size.
Sometime's it's important to know how "smart" the LV compiler is- saves lots of unnecessary code optimization