LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My LabVIEW program runs slower and slower with the increase of running time.

My LabVIEW program runs slower and slower with the increase of running time. I don't know why. Does it matter that there is a large amount of data in the program's shift register? Would it be better to transfer these data using functional global variables?

0 Kudos
Message 1 of 3
(2,412 Views)

If you grow arrays forever in a shift register, your code will slow down and eventually you'll run out of memory.

How much is "a large amount"? What is the datatype?

Arrays need to be contiguous in memory, and as they grow,  finding a sufficiently large chunk of contiguous memory becomes harder and harder. A functional global won't change that. I am not sure what you mean by "transfer". Transfer from where to where?

Can you show us your code?

0 Kudos
Message 2 of 3
(2,382 Views)

Your question seems a bit strange.  "In my main VI, I'm having issues with this shift register.  Should I move the shift register into a subVI (FGV) to solve the problem?"

 

If the problem is related to the shift register, it's going to continue being a problem regardless.

 

The problem you're likely running into is related to memory management and unbounded growth.

 

A common first algorithm for grabbing dynamically sized memory is to grab a number.  When you need to exceed that value, grab twice that size, copy everything from the first block into the second, add the new values, then release the first block.  

If that's the method LV uses, the more you grow, the longer that action takes (it takes more time to move 20 elements than 10).  

 

Given the behavior you're describing, that sounds like what you're likely running into.

 

Fixing that is typically done with one of two things:

1) maintain a smaller set of data in memory.  Log out older data points so you don't need them in memory

2) Initialize the maximum size array you'll need before the application runs.  Then, replace array subsets rather than continue to add to a dynamically sized array.

0 Kudos
Message 3 of 3
(2,314 Views)