B Chavez Posted January 17, 2006 Report Share Posted January 17, 2006 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. Quote Link to comment
crelf Posted January 18, 2006 Report Share Posted January 18, 2006 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 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. Quote Link to comment
Rolf Kalbermatter Posted January 18, 2006 Report Share Posted January 18, 2006 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 Quote Link to comment
B Chavez Posted January 18, 2006 Author Report Share Posted January 18, 2006 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 Quote Link to comment
crelf Posted January 19, 2006 Report Share Posted January 19, 2006 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: "Every bit is sacred!") Quote Link to comment
nudalakasim Posted January 29, 2006 Report Share Posted January 29, 2006 (I can hear my old programming teacher who'd worked on ENIAC spinning in his grave: "Every bit is sacred!") Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.