Jump to content
hooovahh

Purpose of Close Reference

Recommended Posts

I understand cleaning up references is generally a good thing, but is there a reason the JKI State Machine attempts to close the This VI reference of a VI that is in memory? This in my mind is basically a no-op and can be removed because the close can't remove the VI from memory since that is the VI that is running.

 

Which brings me to question why we even get a copy of the This VI reference and put it in the shift register. If you have a property or invoke node set to the VI Server class "VI" then you can leave the reference unwired and it assumes "This VI", which is actually seen in the "Initialize Core Data" case.

 

Is there a good reason to keep a copy of This VI in the cluster? And if so is there a good reason to have a Close Reference in cleanup?

  • Like 1

Share this post


Link to post
Share on other sites

That's a great question, Brian! I tend to agree with your observations and thinking. I'll check in with others at JKI to see if I learn more about the history behind this and any corner-cases where this serves a useful purpose.

Share this post


Link to post
Share on other sites
On 6/2/2015 at 10:30 AM, hooovahh said:

I understand cleaning up references is generally a good thing, but is there a reason the JKI State Machine attempts to close the This VI reference of a VI that is in memory? This in my mind is basically a no-op and can be removed because the close can't remove the VI from memory since that is the VI that is running.

Which brings me to question why we even get a copy of the This VI reference and put it in the shift register. If you have a property or invoke node set to the VI Server class "VI" then you can leave the reference unwired and it assumes "This VI", which is actually seen in the "Initialize Core Data" case.

Is there a good reason to keep a copy of This VI in the cluster? And if so is there a good reason to have a Close Reference in cleanup?

 

Hey Brian.  I just asked about this, and the primary thinking is this: even though it's a no-op, it serves to document how to user the "Data: Cleanup" frame.

image.png

Also, in the case where someone might change the VI Reference constant to an Open VI Reference, it's helpful that we're actually closing it. Why would someone call Open VI Reference? I'm not sure, but one thing I thought of is when a VI wants to hold a reference to itself open, so that if it's Front Panel isn't visible and it's running because someone else opened it by reference to it, then it won't be "garbage collected" (aborted and destroyed) when the reference count goes to zero (since it won't go to zero if it opens an explicit reference to itself). 

image.png

Does that make sense? Do you have any thoughts about that?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

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