Cat Posted March 21, 2009 Report Share Posted March 21, 2009 I have a main program that calls a lot of subvis dynamically. When the user selects a particular function, I open a reference for the corresponding vi and run the vi. When the user exits the vi, I close the front panel and close the reference. This works fine, except... I have a vi I call "Big Top.vi" that doesn't do anything but hold all those dynamically called vis on its BD, basically for debugging and organizing (this was originally developed in the pre-LVproject days). If I have Big Top open (not running, of course), and I call a vi dynamically with the main program, after the dynamically called vi exits and the reference is closed, the vi is still running. I can't see it (the front panel is closed), but if I open Error List, that vi is in there as "already running". Even after the main program is exited, the dynamically called vi is still running. I've checked, and the reference is indeed closed when it's supposed to be. This isn't a huge deal, since the code will be really run as an executable. And now that I know what's causing the problem I'll just manually clean everything up when I'm working with the source code, or not open Big Top in the first place. But my question is what's going on?? I'm assuming it has this issue because the vis aren't normally in memory when they're called, but when Big Top is open they are in memory since they're parked on the BD. But I don't get how this keeps the called vi running even after its reference has been closed. Or is there some other step for *really* closing the vi that I'm missing? Cat Quote Link to comment
Grampa_of_Oliva_n_Eden Posted March 21, 2009 Report Share Posted March 21, 2009 QUOTE (Cat @ Mar 20 2009, 08:46 AM) I have a main program that calls a lot of subvis dynamically. When the user selects a particular function, I open a reference for the corresponding vi and run the vi. When the user exits the vi, I close the front panel and close the reference.This works fine, except... I have a vi I call "Big Top.vi" that doesn't do anything but hold all those dynamically called vis on its BD, basically for debugging and organizing (this was originally developed in the pre-LVproject days). If I have Big Top open (not running, of course), and I call a vi dynamically with the main program, after the dynamically called vi exits and the reference is closed, the vi is still running. I can't see it (the front panel is closed), but if I open Error List, that vi is in there as "already running". Even after the main program is exited, the dynamically called vi is still running. I've checked, and the reference is indeed closed when it's supposed to be. This isn't a huge deal, since the code will be really run as an executable. And now that I know what's causing the problem I'll just manually clean everything up when I'm working with the source code, or not open Big Top in the first place. But my question is what's going on?? I'm assuming it has this issue because the vis aren't normally in memory when they're called, but when Big Top is open they are in memory since they're parked on the BD. But I don't get how this keeps the called vi running even after its reference has been closed. Or is there some other step for *really* closing the vi that I'm missing? Cat If the dynamic open a ref to itself, it can keep itself open. Ben Quote Link to comment
Cat Posted March 21, 2009 Author Report Share Posted March 21, 2009 QUOTE (neBulus @ Mar 20 2009, 09:51 AM) If the dynamic open a ref to itself, it can keep itself open. I looked all over for other calls before I realized the problem only happened when Big Top was loaded. So no, I don't think it's calling itself. Quote Link to comment
Grampa_of_Oliva_n_Eden Posted March 21, 2009 Report Share Posted March 21, 2009 QUOTE (Cat @ Mar 20 2009, 09:19 AM) I looked all over for other calls before I realized the problem only happened when Big Top was loaded. So no, I don't think it's calling itself. Yes that will do it also. The trick is to get the access count down to zero and as long as the Big Top is open.... Ben Quote Link to comment
djolivet Posted March 21, 2009 Report Share Posted March 21, 2009 The rule is that a VI will be unloaded from memory when its front panel is not visible and no references to it are open. When you run your code WITHOUT the Big Top open and the VI that opened the dynamic VI closes its reference, there is no longer any references to the dynamic VI, so LabVIEW unloads the VI from memery (essentially aborting it) When you run your code WITH Big Top open and the VI that opened the dynamic VI closes its reference, there is still a reference to the dynamic VI on Big Top's block diagram, therefore the dynamic VI continues executing. What I usually do, is launch the dynamic VI, and provide a way to command the dynamic VI to stop (VI Server, Queues, etc). The dynamic VI can then perform any clean up and stop gracefully. This would allow you code to function properly regardless of Big Top Hope this helps Quote Link to comment
Cat Posted March 21, 2009 Author Report Share Posted March 21, 2009 QUOTE (djolivet @ Mar 20 2009, 10:35 AM) The rule is that a VI will be unloaded from memory when its front panel is not visible and no references to it are open. When you run your code WITHOUT the Big Top open and the VI that opened the dynamic VI closes its reference, there is no longer any references to the dynamic VI, so LabVIEW unloads the VI from memery (essentially aborting it) When you run your code WITH Big Top open and the VI that opened the dynamic VI closes its reference, there is still a reference to the dynamic VI on Big Top's block diagram, therefore the dynamic VI continues executing. Now I'm really confused. Maybe the problem is semantics, and I don't understand what you mean by "there is still a reference to the dynamic VI on Big Top's block diagram". Do you mean that just having the icon for the vi on the BD (that never gets run) creates a reference to that vi (as opposed to loading it into memory), and that's the one that's not getting closed?? After I've closed the front panel and exited the dynamic vi, I expect the vi to still be in memory because it's sitting in Big Top. I *don't* expect it to still be running, tho. Maybe I should be using "abort", but that seemed like overkill. Quote Link to comment
Mark Smith Posted March 21, 2009 Report Share Posted March 21, 2009 QUOTE (Cat @ Mar 20 2009, 09:06 AM) Now I'm really confused. Maybe the problem is semantics, and I don't understand what you mean by "there is still a reference to the dynamic VI on Big Top's block diagram". Do you mean that just having the icon for the vi on the BD (that never gets run) creates a reference to that vi (as opposed to loading it into memory), and that's the one that's not getting closed?? After I've closed the front panel and exited the dynamic vi, I expect the vi to still be in memory because it's sitting in Big Top. I *don't* expect it to still be running, tho. Maybe I should be using "abort", but that seemed like overkill. Closing the front panel won't stop a VI that's been loaded dynamically - you can close and then re-open the panel and the VI will still be running. Closing all refs will. As long as the VI is running some sort of blocking process (loop, wait to dequeue, something) and there's a ref around, it will continue to run. Sounds like your VI panel gets closed but it never actually stops except when all refs go dead, so you may want to look at how you command the VI to actually stop. Mark Quote Link to comment
djolivet Posted March 21, 2009 Report Share Posted March 21, 2009 QUOTE (Cat @ Mar 20 2009, 10:06 AM) Do you mean that just having the icon for the vi on the BD (that never gets run) creates a reference to that vi (as opposed to loading it into memory), and that's the one that's not getting closed?? Yes QUOTE (Cat @ Mar 20 2009, 10:06 AM) After I've closed the front panel and exited the dynamic vi, I expect the vi to still be in memory because it's sitting in Big Top. I *don't* expect it to still be running, tho. Maybe I should be using "abort", but that seemed like overkill. Just because you close the panel of a VI doesn't mean it stops running (as you are seeing). Quote Link to comment
Cat Posted March 21, 2009 Author Report Share Posted March 21, 2009 QUOTE (mesmith @ Mar 20 2009, 11:37 AM) Closing the front panel won't stop a VI that's been loaded dynamically - you can close and then re-open the panel and the VI will still be running. Closing all refs will. As long as the VI is running some sort of blocking process (loop, wait to dequeue, something) and there's a ref around, it will continue to run. Sounds like your VI panel gets closed but it never actually stops except when all refs go dead, so you may want to look at how you command the VI to actually stop. You are, unfortunately, right. :-) I just rechecked the loops in the vi and found one that wasn't getting stopped correctly on exit. I didn't notice it when it was running normally; the vi would just stop after the front panel and the reference were closed. That explains why it kept running with another reference open. Thanks! QUOTE (djolivet @ Mar 20 2009, 11:43 AM) Just because you close the panel of a VI doesn't mean it stops running (as you are seeing). Between learning more about references, and finding my programming boo-boo, this has been very educational. Thanks for your help! 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.