altenbach
2007-09-15 17:10:04 UTC
A VI loaded in memory doesn't cost much, unless it allocates huge amounts of memory for data structures. If you are confident that the subVI is only called once to process large amounts of data, you can place a "request deallocation" node on its diagram.
<a href="http://zone.ni.com/reference/en-XX/help/371361D-01/glang/request_dealloc/" target="_blank">http://zone.ni.com/reference/en-XX/help/371361D-01/glang/request_dealloc/</a>
Now the allocated memory for data will get deallocated when the VI has finished its job. Of course this also means that if yo call it again later, it again needs to reallocate memory, so things can get expensive very quickly if you constantly shuffle memory around. In a typical scenario, a subVI is called repeatedly and often with similar amounts of data, so it makes sense that it can retain the allocated data structures between calls.
Can you explain your concerns in more details? What problem are you trying to solve?
If you are running in the development system, You can also make code run a little bit leaner by disabling debugging, for example.
If you are worried about memory use, it helps to optimized the code to limit the number of duplicate data copies im memory. This can often be achieved by limiting the use of local variables, doing operations on large arrays "in place", don't constantly resize arrays (e.g. don't overuse built array, insert into array, delete from array), keep the FP of non-interactive subVIs closed, and so on. Feel free to post some of your subVIs if you think this could be part of the problem.
See also the article on VI memory usage:
<a href="http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/vi_memory_usage/" target="_blank">http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/vi_memory_usage/</a>
<a href="http://zone.ni.com/reference/en-XX/help/371361D-01/glang/request_dealloc/" target="_blank">http://zone.ni.com/reference/en-XX/help/371361D-01/glang/request_dealloc/</a>
Now the allocated memory for data will get deallocated when the VI has finished its job. Of course this also means that if yo call it again later, it again needs to reallocate memory, so things can get expensive very quickly if you constantly shuffle memory around. In a typical scenario, a subVI is called repeatedly and often with similar amounts of data, so it makes sense that it can retain the allocated data structures between calls.
Can you explain your concerns in more details? What problem are you trying to solve?
If you are running in the development system, You can also make code run a little bit leaner by disabling debugging, for example.
If you are worried about memory use, it helps to optimized the code to limit the number of duplicate data copies im memory. This can often be achieved by limiting the use of local variables, doing operations on large arrays "in place", don't constantly resize arrays (e.g. don't overuse built array, insert into array, delete from array), keep the FP of non-interactive subVIs closed, and so on. Feel free to post some of your subVIs if you think this could be part of the problem.
See also the article on VI memory usage:
<a href="http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/vi_memory_usage/" target="_blank">http://zone.ni.com/reference/en-XX/help/371361D-01/lvconcepts/vi_memory_usage/</a>