01-02-2009 05:04 PM
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
Solved! Go to Solution.
01-02-2009 08:45 PM
01-03-2009 09:13 AM
01-03-2009 11:23 AM
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?
01-04-2009 10:13 AM
01-04-2009 01:40 PM
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... 😉
02-03-2016 01:28 PM
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.
02-03-2016 02:02 PM
@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.
02-04-2016 02:40 AM
@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).