LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How safe is it to use Local Variables

HI,

I have an application which has a bunch of local variables ( couldnt find a way to get rid of them ). How safe is it using local variables...does it affect the performance....

Thanks
0 Kudos
Message 1 of 4
(2,985 Views)
The quick answer is that yes - local and global variables can have a big effect on performance. The app note "LabVIEW Performance and Memory Management" touches on some of the issues and there was a recent thread about it on the info-LabVIEW mail list. If you want to search info-LabVIEW, there's a search engine at http://www.searchview.net/. The posts occurred within the last week under the subject "Memory Release".
0 Kudos
Message 2 of 4
(2,985 Views)
"ace" wrote in message
news:506500000008000000BA560000-1027480788000@exchange.ni.com...
> HI,
>
> I have an application which has a bunch of local variables ( couldnt
> find a way to get rid of them ). How safe is it using local
> variables...does it affect the performance....

It can, but not necessarily. If the application is too slow and your locals
are large or repetitively used then you may be able to speed it up by
getting rid of them. But if your application works satisfactorily then why
worry? I'm not saying be sloppy, but just don't sweat the small stuff.

OTOH watch out you don't get in a race condition. Any diagram where you
read and write to the same variable is dangerous and you should be very
careful.
0 Kudos
Message 3 of 4
(2,985 Views)
There's nothing wrong with using local and global variables, as long as you have exhausted all other possible alternatives first, which it looks like you have. Sometimes you just have to 'bite the bullet' and use them. Yes they do affect the performance, but as long as your program runs acceptably, then dont worry.

You can look at your program performance by using the Profile window (in LV 6.0, found in Tools>Advanced>Profile VIs). You can measure the memory usage and speed of your VIs with this tool, and if you are having problems with performance, you can compare different methods to find the most efficient. If you want more information on improving performance there is a Performance Tips section in the LV 6.0 Help, and if you can get hold of a
copy, the LV Basics II course manual covers this in more detail (Lesson 7).

I hope this has been of some help to you..

Kim
0 Kudos
Message 4 of 4
(2,985 Views)