01-02-2009 11:42 AM
I am opening reference to a VI on a RT target on the press of a button. I want to run this vi in the background until a certain shared variable goes true. In this case, do I also have to close the reference when the variable goes true?
What happens if I repeatedly (after each button press) open a reference to the same vi and run it, without closing the reference?
Also, what exactly happens when I open reference to an application on a RT target? Do all its VIs get loaded into the memory?
01-03-2009 10:05 AM
I assume that you mean that you're doing an Open App Reference to the RT target's IP address and then use that app reference to get a reference to a VI running there. In this case, I'm pretty sure that the hierarchy does not get loaded in your local instance.
What happens is that you only get a connection to the VI which is already running (and therefore loaded) in the remote instance and can then interact with that VI on a limited level. I never looked into this to make sure that this is so, but this makes sense for all kinds of reasons and is supported by the fact that opening such a reference takes less than a second. If you had to transfer and load the entire hierarchy, it would take longer.
As for the reference, you should close it. While LabVIEW is pretty smart at deallocating stuff like this and while a reference is only 4 bytes, you should not rely on this. Another option is to use a small LV2 global to obtain the reference. In the Get action, you can check a flag or the reference to see if you have a valid reference and if you don't, open a reference and put it in the USR. After that, you can get the reference from the USR.