Jump to content

Questions about Control References


Recommended Posts

I have a few questions about using Control references, any input will be appreciated.

1. Should control references be 'closed' when no longer needed? I've played around with them and it doesn't seem to do anything if you do close them.

2. If I do need to close them, do I need to close every instance where I have place one on my block diagram?

3. Is any of this considered bad practice? My first two questions may be insignificant if I shouldn't be using Control references anyways.

Thanks in advance.

Link to comment

Have a look at this recent post on the NI Discussion Forum - it answers exactly what you're after (and more).

In summary: "VI-Server "Static" references (this App, this VI, Control-references) allocate memory (once). If memory's an issue, close them, otherwise they close automatically when Application exits."

As for them being bad practise - I suppose it's like anything else - it depends on how you use them :rolleyes: Control references are great, and can open up a whole lot of control (pun intended) that was previously either unavailable or really messy to acheive.

Link to comment
I have a few questions about using Control references, any input will be appreciated.

1. Should control references be 'closed' when no longer needed? I've played around with them and it doesn't seem to do anything if you do close them.

2. If I do need to close them, do I need to close every instance where I have place one on my block diagram?

3. Is any of this considered bad practice? My first two questions may be insignificant if I shouldn't be using Control references anyways.

Thanks in advance.

It depends on the LabVIEW version. Before version 7 you had to close every VI server reference to avoid leaking memory. Since version 7 you only have to close VI server references that you explicitedly open with an Open function. But LabVIEW is forgiving if you try to close VI references you retrieved from property nodes for instance and recognizes that that are owned references and does nothing on them. So as a matter of fact I usually still use the Close Reference function on all VI server references independant if they are explicitedly or implicitedly opened VI references.

Rolf Kalbermatter

Link to comment

Thanks for the help, very useful info.

I guess I knew that the safe approach would be to close all references, and I'll start doing that. I was mostly concerned about Control References (right click a control -> Create -> Reference). It seems that they do not change whenever they are read and therefore do not 'need' to be closed, so I don't need to go back and fix old code.

Thanks again

Link to comment
I was mostly concerned about Control References (right click a control -> Create -> Reference). It seems that they do not change whenever they are read and therefore do not 'need' to be closed, so I don't need to go back and fix old code.

Yep - that's my interpretation as well. The control reference is created (it's not very big as it's just a reference to a control, not the data within it), so I wouldn't bother closing it.

(I can hear my old programming teacher who'd worked on ENIAC spinning in his grave: :nono: "Every bit is sacred!")

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.