LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

why not to store notifier reference in global

Solved!
Go to solution

Hi all,

 

I am working with notifiers and queues in multiple VIs. I have strange behaviours, when I store the queue and notifier references in global variables.

I have read some entries in this forum, and some says, it is a "bad idea", that "should not be done", to store the refs in globals.

 

Can anybody tell me, what is the real background?

 

regards

mitulatbati

0 Kudos
Message 1 of 3
(2,381 Views)
Solution
Accepted by topic author mitulatbati

Besides that globals are simply evil (just slightly an over the top statement as I really advocate to minimize the use of globals to nothing more than a status boolean or sometimes some single skalar value), all LabVIEW refnums employ some garbage collection.

 

The reason to use globals usually implies that you want to create the according resource at one place and use it someplace else. But that often does not work with LabVIEW refnums if the producer and consumer are not in the same VI hierarchy (for instance you create the resource in a startup VI and then spawn a plugin VI that continues while the startup VI terminates). All LabVIEW refnums are automatically disposed at the moment the top level VI in whose hierarchy the refnum was opened goes idle. So at the time your plugin VI gets to work, the refnum and its object has been already disposed and is therefore invalid.

Rolf Kalbermatter
My Blog
Message 2 of 3
(2,379 Views)
Thanks Rolf!
0 Kudos
Message 3 of 3
(2,361 Views)