LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array secure memory place

Solved!
Go to solution

Hello.

I'm working with a "big" array, and I would like to know if I do it right.

I'm concatenating data (SGL) on my program and with it, builing a bigger array every loop iteration. I calculated that I need an array with about 200000 items. If I'm right, its not good to worked with a shift register becuase if the array goes bigger every iteration Labview have to alocate the new array every time. So, what I'm doing is initialize an array with 200000 NaN items and after it fill it with a = constant. Its that right?

Thanks

Download All
0 Kudos
Message 1 of 4
(2,740 Views)
Solution
Accepted by topic author Navarro_

Hi Navarro,

 

initializing an array beforehand to the correct (or needed) size is recommended.

 

Case "period": Deleting that array later on by replacing it with an empty array constant is nonsense.

Case "save": Adding new elements to your array is nonsense - why did you initialize it before?

 

Use InitArray in conjunction with ReplaceArrayElements!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,731 Views)

Hi.

Thanks for your answer, I get it as the solution.

Only one more question: I deleted the array on "period" case, and I added new elements on "save" case because I thought that the array allocation in memory was not changing. I secure place for 200000 items, and then I can do whatever I want with the array because the allocation is still the same, isn't it?

 

Have a nice day.

0 Kudos
Message 3 of 4
(2,708 Views)

Hi Navarro,

 

no, it isn't so…

 

LabVIEW has it's own memory manager - and you nearly to no influence on its behaviour! (Ofcourse apart from good programming and keeping all the style guide recommendations in mind - there's an article in the LabVIEW help on that very topic!)

 

First you init an array to hold 200k elements. Then you release that memory by setting that array to size of zero elements. The memory manager might use this to release (or re-use) the memory as it is currently unneeded!

Later on you build up an array the (nearly) worst way using BuildArray and adding single elements at the end. This will keep the memory manager busy all the time as it has to reallocate the memory space for your array constantly!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(2,697 Views)