01-06-2025 12:21 PM
I have a large application that uses subpanels to display a large number of possible HMI VIs, one at a time. The LabVIEW example "Multiple VIs in a Subpanel" launches all the VIs at the start of execution and allows them to keep running in the background as they are swapped in and out of the subpanel. Instead, I want to abort and remove from memory all but the VI currently displayed in the subpanel. Some of my HMI VIs are computation intensive and/or involve communication to other devices that only need to occur if someone is looking at that VI. I have created the attached simple project to illustrate what I am trying to do. It is a modified version of the NI example project. I believe that to release all the resources associated with the VI that I am removing from the subpanel, I need to close the reference to it. However, if I close the reference, I get error 1307 when I try to insert the incoming VI in the subpanel. This makes no sense to me, since the Insert VI method is acting on a completely different reference. It seems like a bug in LabVIEW itself, but maybe I am missing something. Can anyone tell me what is going on?
Note that my VIs are set to be re-entrant, because I may have multiple monitors and therefore multiple subpanels displaying the same VI simultaneously.
01-06-2025 02:41 PM
I can't see your block diagram because it's position is beyond the limits of my screen.
01-06-2025 03:22 PM
If you close the reference after calling Remove VI the error doesn't seem to happen.
01-06-2025 03:43 PM
Not according to what I am seeing. If I Remove VI before closing the reference, then the Close Reference.vi throws error 1026.
01-06-2025 03:45 PM
@Drouilhet wrote:
Instead, I want to abort and remove from memory all but the VI currently displayed in the subpanel.
Not sure how your architecture is set up, but a suggestion. Do not use the Abort VI method to close your VI. Instead send a message to your VI to stop. That way, any references in it, memory structures, etc, can be gracefully exited. Rather than use the Run VI method, use the more modern Call and Forget Method, from that call you close the VI reference directly, so no need to close it later.
01-06-2025 03:47 PM
Note that you won't see this behavior when the first VI loads on startup. It's only when you select a different VI.
01-06-2025 03:50 PM
@Drouilhet wrote:
Not according to what I am seeing. If I Remove VI before closing the reference, then the Close Reference.vi throws error 1026.
You'll note that's a different error: apparently removing the VI closes the reference previously obtained from "insert vi." So explicitly closing that reference does nothing.
01-07-2025 04:01 AM
@Drouilhet wrote:
I believe that to release all the resources associated with the VI that I am removing from the subpanel, I need to close the reference to it. However, if I close the reference, I get error 1307 when I try to insert the incoming VI in the subpanel.
You need to close all references to the VI. An open (or hidden!) front panel, in a
SubPanel or not, is also a reference...
Closing a reference doesn't automatically remove it from a SubPanel. If the panel is open, closing a reference doesn't close the panel.
So, you need to close all references and close the panel or remove the panel from the subpanel.
Of course, it would be convenient to get the subpanel reference from the VI reference, but it has been decided that that's a horrible idea.
01-07-2025 04:32 AM
wiebe@CARYA wrote:
@Drouilhet wrote:
I believe that to release all the resources associated with the VI that I am removing from the subpanel, I need to close the reference to it. However, if I close the reference, I get error 1307 when I try to insert the incoming VI in the subpanel.
Of course, it would be convenient to get the subpanel reference from the VI reference, but it has been decided that that's a horrible idea.
You can get the VI ref from the Subpanel, i just learned ...
01-07-2025 09:27 PM
Perhaps this.