LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How long does subVI stay in memory

Solved!
Go to solution

Hi,

 

      I would like to know how long does a subvi stay in memory? If it is not used anymore will LabVIEW automatically close it? Thanks!

 

      Tom

0 Kudos
Message 1 of 9
(4,233 Views)

A subVI stays in memory until the top-level VI finishes executing.

 

Jim 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 9
(4,215 Views)
Solution
Accepted by topic author tom_z
That is not correct. A subVI will remain in memory as long as it is loaded, which means it doesn't matter if the top VI is running or not, or has finished running. If you are referring to any data the subVI may generate, then it depends on whether the data is displayed on front panel indicators and whether the subVI front panel is open. If the data is displayed on a front panel indicator, and the subVI front panel is open, then obviously that data has to remain in memory.
Message 3 of 9
(4,191 Views)

Doh!  Thanks.  I got my wires crossed with the behavior of a Real-Time system but, even then, the difference is that the OS unloads a VI immediately after execution is finished.  Is that right?

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 9
(4,174 Views)
No. The VI will remain in memory as long as it's open or the calling VI remains open. As I indicated, it does not matter whether it's running or not or has finished running.
Message 5 of 9
(4,137 Views)

Overall, we don't have enough information to fully answer the question, because the question is not very specific.

 

For example:

if the subVI is called dynamically, it probably can leave memory once it is closed.

If the subVI is reentrant, It can have multiple instances in memory.

 

To have a subVI in memory is typically irrelevant in terms of the memory the code alone occupies. More serious is the amount of data structures allocated by the subVI. Here we have some tools, e.g. the "request deallocation" primitive. This can be useful if a subVI is called only once, and then never again, but needs gigantic data structures. Typically, subVIs are called multiple times with similar data structures, so it would be a mistake to constantly deallocate, only to reallocate a few nanoseconds later.

 

As Smercurio_fc already mentioned, another important question for performance tuning is if the front panel is in memory or not. A subVI that does not need to have the FP in memory executes often much faster and takes less memory. It is thus important not to have the FP of subVIs open unless there is a need for interaction. Certain coding habits (e.g. use of some invoke nodes or some property nodes) also force the FP in memory, even if the FP is not shown. This is documented in the help for each method/property so it is important to avoid these if they are not really needed.

 

 In summary, it would be interesting to know what exact concerns the OP had when he asked " I would like to know how long does a subvi stay in memory?". 😄

 

There has to be more to the question... 😉

Message 6 of 9
(4,127 Views)

This is a relatively old thread so I hope I get a response.

 

We have a weird phenomena going on.  We wrote a simple VI that finds all VI's in memory.  I can open a project, run the main VI and watch LabVIEWs memory grow in task manager.  Then I close the VI and then close the project and go back to the initial labview start screen.  The memory does not drop.  When we run the utility VI to see what is in memory we see many VI's listed in memory but not exectuting.  Why are they still in memory if the main VI and project have been closed?  If I run memory and profile it says they are not using any memory but according to task manager something in labview is holding onto the memory created when we ran the main vi - again this has been closed along with the project.

0 Kudos
Message 7 of 9
(3,188 Views)

@DarkLordOfG wrote:

This is a relatively old thread so I hope I get a response.

 

We have a weird phenomena going on.  We wrote a simple VI that finds all VI's in memory.  I can open a project, run the main VI and watch LabVIEWs memory grow in task manager.  Then I close the VI and then close the project and go back to the initial labview start screen.  The memory does not drop.  When we run the utility VI to see what is in memory we see many VI's listed in memory but not exectuting.  Why are they still in memory if the main VI and project have been closed?  If I run memory and profile it says they are not using any memory but according to task manager something in labview is holding onto the memory created when we ran the main vi - again this has been closed along with the project.


I haven't found a good explanation for that yet.  As a precaution, I close down LabVIEW completely if I need to make sure there are no VIs in memory.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 9
(3,176 Views)

@DarkLordOfG wrote:
Then I close the VI and then close the project...
When we run the utility VI to see what is in memory we see many VI's listed in memory but not exectuting.  
Why are they still in memory if the main VI and project have been closed?

This sounds wrong. If the VIs were loaded in the project context, they should be completely unloaded when the project is closed. My guess would be that either you're loading VIs not in the project or you're not closing the project or your utility VI does not do what you think it does. I would have to see something more concrete than this description.

 

In either case, the question of how much memory LV is actually using is separate from the question of when that memory is released. It is possible for LV to decide not to release that memory because it might need it again later (the "I'm playing with all the toys" syndrome).


___________________
Try to take over the world!
0 Kudos
Message 9 of 9
(3,140 Views)