Showing results for 
Search instead for 
Did you mean: 

Best way to remove local variables



I have been told that I need to remove all the local variables in my VI, because they are slow.  I can not seem to find a good option for replacing them but keeping the same functionality.


What I am using the local variables for is to update 3 different graphs on the front panel from 3 different sources.  Each of these sources are located in while loops so that data can be acquired asynchronously.  In closing these 3 while loops is a case statement.  The case statement is for switching between acquiring and saving the data or just acquiring data.  The local variables are used to update the indicators and graphs from the acquiring and saving data case.  It is these local variables that I need to remove.


Does anyone have any suggestions?


-- Z

0 Kudos
Message 1 of 15



The procedure I usually use is to pop-up on the local and Find the Terminal.  Then just run a wire from the terminal to whatever the local is connected to.  Delete the local.


However, from your description of your VI it seems that you may need to get data from the while loops while they are still running.  If that is the case you may need to use a queue or an Action Engine to transfer the data.


While loops inside a case structure sounds like trouble looking for a place to happen.  Look at the Producer/Consumer Design Pattern to see if it might be more appropriate for your application.  This pattern uses queues to move data between the two loops without needing locals.



0 Kudos
Message 2 of 15



I am using the Queue to take in the data and then to write it out as a slower process.  The local variables are just used for display and stopping the while loops.  I don't use the local variables to store or transfer data between while loops.  I will look at the Action Engine, but I am unsure if that is going to do what I want. 


-- Zurvan

0 Kudos
Message 3 of 15

Are you sure that your speed concern is due to local variable?  You can attach your code, so we can look at it?


Kudos and Accepted as Solution are welcome!
0 Kudos
Message 4 of 15

I will see if I can get a release on the code or not, then a very striped down version that does not include all additional sub vi's that are needed for this VI.  At last count there are over 30 sub VI's that I use.

0 Kudos
Message 5 of 15

From your description I tend to agree with jyang that the local variables may not be the cause of your slow performance.  While there are probably better ways to do what you are doing with the locals, for those purposes you may not have much of a problem with race conditions.


Use the Profile Performance and Memory tool to help you determine where the bottlenecks are.



0 Kudos
Message 6 of 15

A thing that may slow down a VI. May be poor designed array operations. And even mode bad are poor designed array operations combined with locale variables. But as mentioned use the profiler to which VIs that consume your time.

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 15


Zurvan wrote:

I have been told that I need to remove all the local variables in my VI, because they are slow.


Who told you that?


As others have said, local variables typically don't cause slowdown (They cause additional datacopies in memory, have the potential of causing race conditions and cause messy code).



  • What is "slow" in your definition? (missing data, cannot keep up with the instrument, slugging UI, etc.).
  • What is the CPU use when your program runs?
  • So apparently you have a loop that updates all indicators from local variables. What is the loop rate of that display loop? Do you spin that millions of times per second or pace it at a reasonable rate? How much data is in the graphs?
  • Remember, a graph does not need to update unless the data changes.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 8 of 15

Although the Locals may not be the culprits for the slowdown, you are still encouraged to remove them if possible.  😉


All kidding aside...  Instead of guessing at what could cause the slower code, can you post what you have?

0 Kudos
Message 9 of 15

How often do you update the screen/display. Due to the limitation of the human eye. An updating frequency of about 20 times per second may appear as live and you can hardly see the difference from say updating at 1 KHz rate. In fact I think the 1 KHz display may produce more flicker. The trick is process data in chunk's. And cut down on the update rate of the indicators

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 10 of 15