LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

subpanel: when to close reference?

Solved!
Go to solution

Hi, just a quick question if anyone can clearify it I would thank you so much. 

 

I found the subpanel example called "Simple Subpanel.vi" and it put an idle while loop to "hold" the front panel of the invoked vi, here it is the "plugin1.vi". (Sorry I'm still not quite clear why it needs the idle while loop here.)

subpanel example.png

However, if one put the "close vi" after the while loop, like the one I modified, is there a chance that the vi will overflow the PC memory after long time of running? What's the difference of these two methods?

 

subpanel mod.png

0 Kudos
Message 1 of 11
(4,596 Views)
I mean, does it matter at all when to close the reference? Thank you.
0 Kudos
Message 2 of 11
(4,588 Views)

Close the reference when you are done with it.  If you were to modify the VI in the subpanel, while it is in the subpanel you may need the VI reference, and closing it before using it would cause the reference to become null.

 


@thitchen007 wrote:

 

However, if one put the "close vi" after the while loop, like the one I modified, is there a chance that the vi will overflow the PC memory after long time of running? What's the difference of these two methods?

 


Why would closing the reference after the while loop cause memory to grow?  The only reason LabVIEW's memory would grow is if you opened new VI references, but never closed the old ones. 

0 Kudos
Message 3 of 11
(4,558 Views)
By "modify the VI in the subpanel", you mean interacting with the front panel of the vi in the subpanel? What I can see here is that when it's running, the given LabVIEW example "Simple Subpanel. vi" closes the reference before the while loop stops, but I can still switch buttons on the front panel of the vi in the subpanel, sorry I didn't quite follow you here.
Or you mean in the block diagram where I need to modify the VI? That should be done before closing the reference?

Hooovahh wrote:

Close the reference when you are done with it.  If you were to modify the VI in the subpanel, while it is in the subpanel you may need the VI reference, and closing it before using it would cause the reference to become null.

 


thitchen007 wrote:

 

However, if one put the "close vi" after the while loop, like the one I modified, is there a chance that the vi will overflow the PC memory after long time of running? What's the difference of these two methods?

 


Why would closing the reference after the while loop cause memory to grow?  The only reason LabVIEW's memory would grow is if you opened new VI references, but never closed the old ones. 


I'm just debugging a bigger program and just want to eliminate possible reasons one by one. Thank you for the comment!

0 Kudos
Message 4 of 11
(4,537 Views)
Solution
Accepted by thitchen007

Lets say I load my VI into a subpanel, then after it is in the subpanel I want to show or hide the menu bar.  I can use a Property Node to show or hide the menu bar of the VI in the subpanel, but I can only do this using the reference to the VI if it hasn't been closed yet.  In this case you don't want to close it until you are done with it.

 

You are not leaving references opened indefinitely in either case you showed, so there is no memory issue with either method.

Message 5 of 11
(4,534 Views)

The "Best Practice" here is to set "AutoDispose" = TRUE and not to use the Close Ref at all.


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 11
(4,533 Views)

Thanks for your illustration, kudos for you!


@Hooovahh wrote:

Lets say I load my VI into a subpanel, then after it is in the subpanel I want to show or hide the menu bar.  I can use a Property Node to show or hide the menu bar of the VI in the subpanel, but I can only do this using the reference to the VI if it hasn't been closed yet.  In this case you don't want to close it until you are done with it.

 

You are not leaving references opened indefinitely in either case you showed, so there is no memory issue with either method.


 

0 Kudos
Message 7 of 11
(4,513 Views)

@JÞB wrote:

The "Best Practice" here is to set "AutoDispose" = TRUE and not to use the Close Ref at all.


The subvi's in the subpanel's will not stop by themselves, so it might not work here.

Thanks for the comment!

0 Kudos
Message 8 of 11
(4,511 Views)

@thitchen007 wrote:

@JÞB wrote:

The "Best Practice" here is to set "AutoDispose" = TRUE and not to use the Close Ref at all.


The subvi's in the subpanel's will not stop by themselves, so it might not work here.

Thanks for the comment!


That's OK that the sub-vi closes whenever, AutoDispose handles that by closing the reference when it is no longer needed.  Really, Auto Dispose is a nice featureSmiley Wink


"Should be" isn't "Is" -Jay
Message 9 of 11
(4,486 Views)

@JÞB wrote:

@thitchen007 wrote:

@JÞB wrote:

The "Best Practice" here is to set "AutoDispose" = TRUE and not to use the Close Ref at all.


The subvi's in the subpanel's will not stop by themselves, so it might not work here.

Thanks for the comment!


That's OK that the sub-vi closes whenever, AutoDispose handles that by closing the reference when it is no longer needed.  Really, Auto Dispose is a nice featureSmiley Wink


Ok, I'll try it out, thanks for the comment!

0 Kudos
Message 10 of 11
(4,473 Views)