08-23-2005 06:20 PM
08-23-2005 09:38 PM
If you are writing code where this sort of limit is an issue, you have a lot biggers problems on your hands than what the limit is...
Mike...
08-24-2005 02:08 AM
I don't know about such a limit, and I think that if there is one, it will probably be high (255?) ,but to expand on what Mike said, using globals is prone to race conditions and bad memory performance and using a lot of globals is prone to a lot of... (you know the rest). The very weird things (what are they?) are probably the result of a race condition. Maybe that class you attended wasn't that good.
There are various ways of passing data between VIs, the best of which is by creating proper inputs and outputs for your VIs and using wires to pass the data. If that isn't possible, you should group the data in logical groups which you can pass together and not pass each control on its own. Another way of minimizing memory hits (and make it somewhat easier to control race conditions) is using alternative global variable approaches, like the LV2 style global. In short, you will probably need to restructure your application to make it easy to work on and to get it to work right.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
If you want any more help, you should give more details, like what are the weird things you see, what is your application supposed to do, how much experience you have, how big is it and so on. If it isn't too big, I suggest you save the files as an LLB (File>>Save With Options>>Development Distribution) and post it here.
08-24-2005 07:11 AM
I Second the previous commnts.
I believe in LV 6.1 and prior there was a limit of 550 controls on any front panel. I believe that would cover the teh globals as well. (No, I did not write a VI with 550 controls, but one of my customers did!).
The other limitation had to do with the nesting of cluster elements. It was a bizarre condition but had to do with the total number # of characters invloved in nesting of cluster objects. eg cluster.element1.sub-element_A.sub-sub-element... had to be less than thansome large number. I believe this was the thread where Rolf Kalbermatter wrote something like,
"Once all of your physical memory is filled up with a single cluster, your application is probably going to suck!?
Please forgive me if I miss quoted.
Ben
08-24-2005 07:31 AM
If you can explain a bit more about your application, we can help you sort out the structural problems in the code that make the global size limit appear to be a problem. There is never a good reason for using a huge number of globals--regardless of how they are arranged.
Mike...
08-24-2005 08:01 AM
08-24-2005 10:00 AM
LabVIEW, C'est LabVIEW
08-24-2005 11:03 AM
08-24-2005 11:42 AM
HI Tbob,
You are going to earn the title of Global Enthusiast if you keep this up
Race conditions are to Globals as Venerial deseas is to sex. If you want to avoid the former then abstain from the latter.
Yes you can use globals.
In fact, I ran a benchmark comparing how fast I can read a global booean vs the same coded as a LV2 global. The Global booean was 6 (or was it 16?) times as fast.
When answering Q's that use phrases like "strange things" we bring up the race condition and point users to LV2's.
Sure text based programmers learn how to handle global access in multi-threaded environments. These types of interaction are implemented by making the global a protected section that are protected using semaphores. This same approach can be used to protect LV globals. Just ensure all reads and writes of teh globals are only done after acquiring the semaphore that protects the global. If you did thisfor all accesses to the global you would not have race conditons with globals.
Unfortunately this is a lot of work because now you have to deal with creating acquiring releasing the semaphores and this has to be done for each value you need to protect from simultaneous access.
Now if there was an easier way well then....
BUT THERE IS!
It turns out that when a VI is not reentrant (like in a LV2) LV implements a scheme that prevents simultaneous execution of the VI. So by using a LV2 you pick-up the resource locking with ZERO EFFORT!
So being lazy, I use the method that is imune from race conditons from the very begining. That way when my customer asks "Can I manipulate the cal values from any of the machines on the network?" I can say "YES, that was functionality is supported by the design".
I could not say that if I implemented the cal via globals.
So that is why I push LV2's and and discorage globals.
Ben
08-24-2005 11:58 AM