LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

large arrays, speed issue

Hi
 
I have a loop in which I change some values in an array or add values to the array (increase its size) using "insert into array", the array is transfered to next iteration using a shift register. The while loop runs at about 30Hz. When my array (two coloums, between 30,000 and 200,000 rows) becomes too big (about 90,000 rows), the while loop can no longer run at 30Hz and slows down.
 
Is there any way to overcome this?
It is as if labview has to read the whole array for every iteration in sted of just writing to the selected position choosen in the iteration (which should not take any longer no matter how large the array is).
 
I remember learning in a programming class, that when working with large arrays, I should always make an array large enough to begin with and then change the values that I wanted changed, in stead of changing the size of the array over and over again. Thereby the program would not have to read the whole array and write it in the memory again, but only change the values of the few cells that was needed.
I know this is true for matlab, how about labview?
Should I do something else that using a shift register?
 
Hope you guys can help me
 
Simon
0 Kudos
Message 1 of 5
(2,500 Views)
In this Link
 
there is a section called 'Avoid Constantly Resizing Data'>>building arrays
 
Just read through it, it might answer a few of ( if not all) your doubts
0 Kudos
Message 2 of 5
(2,497 Views)

Thanks for your fast response.

I used "insert into array" instead of "replace array subset". I hope that helps, havent tested it though.

 

Simon

0 Kudos
Message 3 of 5
(2,491 Views)

I think it did the job, now the only limit to the size of the arrays is my memory.

Can do 2 * 50,000,000 array 32bit numbers - uses about 400Mbyte of ram and can run at full speed.

So I guess when insert into array is used the whole array has to be rewritten in the memory, whereas with replace array subset only the relevant cells are changed in the array already stored in the memory.

0 Kudos
Message 4 of 5
(2,481 Views)
You are correct.  Any time you do an insert into array or build array operation, LV creates a whole new array, copies the data into the right positions, and deletes the old one.  This process fragments your memory, in addition to costing you time.  Using replace array subset is much less costly, often leading to order of magnitude improvements in speed.
0 Kudos
Message 5 of 5
(2,453 Views)