LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bad, Good or Best of Build array function?

Hi all,

I would like to learn to use the build array function better in terms of memory usage. I have attached here a snaphshot of my codes on how I normally use the build array function.

I would like feedback from you in order to use the build array function with more efficient but less memory usage.

Thank you in advance,
keng
0 Kudos
Message 1 of 3
(2,935 Views)

Keng,

That is a loaded question. It assumes that there is a good way to use the build array function in terms of memory usage. Rather than build an array, the most optimal way of constructing an array is to create an array once (outside of a loop) of a know size and then replace elements or subsets of that array in a loop with a shift-register and using the "Replace Array Subset" function. This latter approach is often referred to as operating on data "in place". Building an array requires allocating and dealocating memory each time, but replacing an element or subset of an array merely changes the value of already allocated memory. The later is much faster (even more so as the data gets very large).

For further reading on the topic take a look at the
following PDF File:

LabVIEW� Performance andMemory Management

You can probably find other such documents, articles, and presentations by searching NI's website for keywords like "LabVIEW", "Performance", "Array", "Optimize" "Memory Management", etc.

Best of luck,

-Jim

0 Kudos
Message 2 of 3
(2,935 Views)
Hi Jim,
Thanks for answering my problem.

What if I don't have a known size of a 2D array? Let's say I know the how many columns I need but unsure about the rows. This is because, it depends on the number of readings to be measured set by the user during a test.

However, if you could kindly go back to my question, I have posted a reply comment to Enrique's comment of what I would like to achieve. I have described futher on what is happening in the posted picture.

In the meantime, I will try to implement your suggested solution on using shift register and Replace Array Subset function.

Thanks,
keng
0 Kudos
Message 3 of 3
(2,931 Views)