Jump to content

Implicit vs. Explicit Property Node: Performance Difference?


Recommended Posts

Is there a performance difference between implicitly and explicitly linking a property node to a control or indicator?  I tend to use the explicit variety unless I'm getting a reference to a control/indicator as an input to a sub-VI.  I'm curious if that's considered good practice.

 

Also, when using the explicit variety, does LabVIEW handle cleaning up the control/indicator reference?  It's my understanding that if you create a reference to pass to an implicitly linked property node you need to close it to free up the reference.  I haven't been doing that with the explicit nodes since the whole point, in my mind, of you using them is brevity.

 

Thanks in advance for your help!

Link to comment

Well with an explicit node (is that an official wording?) you don't get a reference, so you couldn't close it anyway even if you wanted to  :rolleyes:

 

Doh!  That was stupid.  Of course, you're right...

 

Still curious about the best practice/efficiency bit...  Oh, and I totally made up that name.  I don't know if there's an official term for it.  Either way, you seem to have understood what I meant, so I stand by it! :)

Edited by mplynch
Link to comment

According to NI's terminology (http://www.ni.com/white-paper/3159/en/), you have implicit and explicit backwards. An implicit property node is one where the reference is not explicitly wired in.

 

You do not need to close references to controls and indicators, although there's no harm in doing so. You can search the NI forums for more details, but the short version is, a front-panel control or indicator is a static object. All references to a single front-panel item have the same value, and you can't invalidate such a reference (the reference stays valid even if you close it because the front-panel items still exists), so closing such a reference is a no-op. You DO need to close references to objects that are created dynamically (.NET and ActiveX objects, for example).

 

Sorry I don't have an answer on your actual question about whether there's a performance difference.

Link to comment

Also, when using the explicit variety, does LabVIEW handle cleaning up the control/indicator reference?  It's my understanding that if you create a reference to pass to an implicitly linked property node you need to close it to free up the reference. 

 

No.  Those are static references that don’t need to be closed (closing them does nothing, so don’t bother closing them).  You can tell if a reference is static by probing it to see if it changes on each call (if it doesn’t, it’s static).

Link to comment

There are several discussions on LAVA about what references should and shouldn't be closed.  The statement that I think holds true about 90% of the time is "If I did something to open a reference in my code, then I need to close that reference".  Did I use OpenVI reference?  Then I need to close it.  Did I use a reference tied to a control?  Or the ThisVI reference?  Then I don't need to.  It starts to get a little confusing with things like an invoke node that can give you a reference to an already open thing.  But throwing close references around shouldn't cause any problems.  LabVIEW will try to close that reference, and realize it can't for some reason, like the VI that owns a control is still in memory and it won't do anything.

 

I've often wrote a simple VI that is just a while loop that runs forever, which will perform some kind of operation that I think might be making new references, over and over without closing.  Then I'll look at the memory usage in the Task Manager.  If it doesn't go up, then that reference doesn't need to be closed, if it does then I need to close it.

Link to comment

There are several discussions on LAVA about what references should and shouldn't be closed.  The statement that I think holds true about 90% of the time is "If I did something to open a reference in my code, then I need to close that reference".  Did I use OpenVI reference?  Then I need to close it.  Did I use a reference tied to a control?  Or the ThisVI reference?  Then I don't need to.  It starts to get a little confusing with things like an invoke node that can give you a reference to an already open thing.  But throwing close references around shouldn't cause any problems.  LabVIEW will try to close that reference, and realize it can't for some reason, like the VI that owns a control is still in memory and it won't do anything.

 

I've often wrote a simple VI that is just a while loop that runs forever, which will perform some kind of operation that I think might be making new references, over and over without closing.  Then I'll look at the memory usage in the Task Manager.  If it doesn't go up, then that reference doesn't need to be closed, if it does then I need to close it.

 

Traditionally all references needed to be closed. This changed around LabVIEW 7.1 for control references. But closing them anyways doesn't hurt as the Close Reference is simply a noop for them.

 

A quicker way to check if you cause memory leaks by not closing a reference is to just typecast it into an int32 and execute it twice. If the numeric value doesn't chance it is a static refnum and doesn't need to be closed. But generally I never do that. The thumb of rule is simple, iIf it is a control reference it doesn't need to be closed, anything else needs closing. And closing a control reference that doesn't need to be closed doesn't hurt so err on the safe side.

 

Ohh and as far as performance difference: You really can spend your valuable developer time much better than worrying about such sub microsecond optimizations. The difference is likely negligable, and definitely to small for me to worry about.

Link to comment

Ohh and as far as performance difference: You really can spend your valuable developer time much better than worrying about such sub microsecond optimizations. The difference is likely negligable, and definitely to small for me to worry about.

 

You're absolutely right: that's what you fine folks are for! :)

 

The question was academic... just trying to learn!

Edited by mplynch
Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.