LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory allocation of Insert into Array and Build Array functions

Solved!
Go to solution

Hi,

 

I am building this big application which will the running for months continuously. So i don't want any memory leaks in application which could probably crash it.

In this application i want to read the strings variables and make any array out of them to finally create report. (All of this i have done.)

 

But i don't know which one of the two functions (Insert into array, build array) i should use for making an array keeping in mind the limited memory i have and without causing my application to over the months due to lack of memory. 

 

So can anyone explain how these two functions handles memory allocation over time i.e. how does LabVIEW know when to release certain memory part which will not be used further?

P.S. i know i can use Replace array subset as my array size is constant but then it will make the whole process like Serial data flow and i want it to be parallel for better readability of my program. 

 

Attached pictures are of the two ways i am considering of for doing it (Super simplified Versions).

 

Thanks in advance,

Rishav

Download All
0 Kudos
Message 1 of 14
(3,078 Views)

If you could periodically write to this report, it would considerably lower your memory usage.  You'd then have to worry about just chunks of memory.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 14
(3,069 Views)

If the array will be continually growing (using either approach) you will eventually run out of memory.

 

A nice no-brainer way to establish a buffer that is of fixed size and will automatically limit the data in the buffer is to use a fixed size queue. That will grow until it reaches the limit you specify and then the oldest data will be tossed as new data comes in.

 

Do NOT read the queue but rather preview it so that data stay in the queue.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 14
(3,056 Views)

Please "supersimplify" less, because your current code fragments are both meaningless.

 

"Insert into array" starting with an empty array is just silly, but most likely the compiler will reduce both to the same machine code.

 

Are you trying to build an evergrowing array in a shift register?

0 Kudos
Message 4 of 14
(3,054 Views)

Thank you for your reply @billko,

 

Yes i am writing the values the to this report after every 5 minutes but does labview release the memory from the previous tasks? otherwise in time i will eventually run out of memory(as i said it will be working day and night for months).

And what do you suggest which function should i use Build array or insert into array?

 

-Rishav

0 Kudos
Message 5 of 14
(3,053 Views)

Thank you for your reply @Ben,

 

No the array size will remain the same as the string variables number will be same only the value input will change.

does LabView allocate new memory each time we call build array?

 

-Rishav

0 Kudos
Message 6 of 14
(3,048 Views)

@rishavpreet wrote:

P.S. i know i can use Replace array subset as my array size is constant but then it will make the whole process like Serial data flow and i want it to be parallel for better readability of my program. 

 


That sentence makes no sense at all.

 

LabVIEW is a graphical language and words are often insifficient to describe it.

0 Kudos
Message 7 of 14
(3,045 Views)

@rishavpreet wrote:

Thank you for your reply @Ben,

 

No the array size will remain the same as the string variables number will be same only the value input will change.

does LabView allocate new memory each time we call build array?

 

-Rishav


No, only when the resulting array is larger than what was previously allocated. Back when I was first exploring this detail I built an VI that repeatedly add a value to an array in a shift register and then tracked how long each iteration needed to complete.

 

At that time (LV 6i maybe) LV would start by allocating maybe 1000 elements for the array. every time if grew beyond the previous allocation, LV would double the size of the array (based on what I saw being used the Task Manager Performance).

 

So not every time, but only when required.

 

LV will also not release memory after a buffer is allocated since it is very expensive time-wise to allocate and deallocate memory.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 14
(3,041 Views)

Thank you for your reply @altenbach,

empty array in insert into array function is because i need to start with empty array each time(but not taking different memory location each time{MY MAIN OBJECTIVE HERE}).

 

No i am will never build an ever growing array. My purpose of building this array is to write it into my report(which will be created in Microsoft Access Database using Database Connectivity Toolkit and not simple spreadsheet otherwise i would've used spreadsheet string)

0 Kudos
Message 9 of 14
(3,040 Views)

@altenbach wrote:

@rishavpreet wrote:

P.S. i know i can use Replace array subset as my array size is constant but then it will make the whole process like Serial data flow and i want it to be parallel for better readability of my program. 

 


That sentence makes no sense at all.

 

LabVIEW is a graphical language and words are often insifficient to describe it.


This mean by using Replace array subset i will have to wire values one by one (basically using as many replace array subset functions as there are variables) where as in build array function i can wire values all at once and get my required array.  

-Rishav

0 Kudos
Message 10 of 14
(3,036 Views)