LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Guidance for closing references

I'm not clear about closing references in this case:

I have a reference to a control that is really a cluster of buttons.

I have a subroutine that reads each button and returns an array of booleans that says if the button has been pressed. In the subroutine I use the "Controls[]" property to get a control reference to each button.

Do I need to close each of the control references in the array from "Controls[]" before I leave my subroutine?

Thanks

Brad
0 Kudos
Message 1 of 9
(3,366 Views)
It is good to close them even though labview(G) will close those references when they are no longer used (like many other languages).
0 Kudos
Message 2 of 9
(3,366 Views)
Lab Viewer.

According to what I have learned recently, you MUST close references explicitly. LabVIEW keeps them open until you either close them explicitly, or quit LabVIEW.

Granted the hit isn't that bad normally, but if you put an open reference in a loop, and run it for days, you can eventually run out of memory, so I hear.
0 Kudos
Message 4 of 9
(3,365 Views)
Thanks for the info ... I knew that for the ActiveX container it's doing by itself open/close reference.
0 Kudos
Message 5 of 9
(3,365 Views)
It is absolutely correct that you must close references explicitly. A VI that I've used takes the control references from a cluster of booleans in order to get the label names. Another user noticed that, unless the references were explicitly closed, that memory was never reclaimed. Since this VI was used to determine the next state in a state machine, a memory leak occurred and the program would eventually crash.
0 Kudos
Message 6 of 9
(3,365 Views)
Underflow,
plese review this document "How Does ActiveX Server Automation Differ from ActiveX Controls?" from NI KnowledgeBase
(http://digital.ni.com/public.nsf/websearch/53BAD0DF6128E846862568E7006E2DF7?opendocument&Submitted)
0 Kudos
Message 7 of 9
(3,365 Views)
Labviewguru,
plese review this document "How Does ActiveX Server Automation Differ from ActiveX Controls?" from NI KnowledgeBase
(http://digital.ni.com/public.nsf/ websearch/ 53BAD0DF6128E846862568E7006E2DF7?opendoc ument&Submitted)
0 Kudos
Message 8 of 9
(3,365 Views)
Brad,

Not sure I am clear myself, but if all you are trying to do is read a cluster of booleans to find an array of booleans for which buttons are true, then all you have to do is convert the cluster to an array, and you will have an array of booleans to match your cluster. If that is your intent, it would seem to me to be the easier way to go.


Good luck
0 Kudos
Message 3 of 9
(3,365 Views)
Are you talking about ActiveX control ?

"Bmarsh" wrote in message
news:5065000000080000002F290000-993342863000@exchange.ni.com...
> I'm not clear about closing references in this case:
>
> I have a reference to a control that is really a cluster of buttons.
>
> I have a subroutine that reads each button and returns an array of
> booleans that says if the button has been pressed. In the subroutine
> I use the "Controls[]" property to get a control reference to each
> button.
>
> Do I need to close each of the control references in the array from
> "Controls[]" before I leave my subroutine?
>
> Thanks
>
> Brad
0 Kudos
Message 9 of 9
(3,365 Views)