01-30-2014 03:18 AM - edited 01-30-2014 03:32 AM
hi everyone, i need your help!
i have tried to call sub-vis in different ways:
sub1.vi call setup - load with callers (normally)
sub2.vi call setup - reload for each call
sub3.vi call setup - load and retain on first call
sub4.vi call dynamically with "open vi reference"
in main.vi, a event structure and a while loop are used for calling sub-vis
another while loop (a application property node in it) is used for checking, which vi is in memory
after main.vi runs, sub1, sub2 and sub3 are in memory. Only sub4 is not. but i think it is wrong.
in my mind, sub2 and sub3 should not be in memory, because they are not called yet.
can you explain it? thanks.
my english is terrible, i hope, you can understand what i mean.
Solved! Go to Solution.
01-30-2014 05:32 AM
can anybody help me?
01-30-2014 06:19 AM
Note: You can simplify the program by moving the 2nd loop to a timeout case.
That's some interesting behaviour, i agree it really shouldn't be in memory, could it be that a VI-ref is in memory but the code isn't?
/Y
01-30-2014 06:43 AM - edited 01-30-2014 06:43 AM
This is expected behavior.
You configured the call by reference node to a static bound VI. So the node will pre-load the VI to increase execution performance as the VI can never change.
In the case of "Load with Callers" (first option, "normal subvi"), this is absolutely clear for everyone, i presume.
With the two other options, it might appear weird, BUT: Have you tried to open and modify the subVIs while your main.vi is running?
You will see the difference there.....
hope this helps,
Norbert
01-30-2014 06:54 AM
thanks for your reply.
"could it be that a VI-ref is in memory but the code isn't?" --- i don't think so.
Lei
01-30-2014 07:08 AM
hi Norbert,
thanks for your reply.
i have tried to open and stop the subVIs while main.vi is running.
ONLY while sub4.vi opened or stoped, the indicator (All VIs in Memory) on the main.vi changed. ---> display or not display the VI name of sub4.vi
another three subVIs have no effect, whether be opened or stoped.
about "modify" what do you mean?
Lei
01-30-2014 07:13 AM
Lei,
unload everything in LV. Restart you main.vi only and execute it.
Now open (manually) sub1, sub2, sub3 and sub4.
Try to modify things in the VIs one after another.
Modify: Move things around, add stuff e.g. an indicator for the loop iterator....
Observe how they behave differently. Close all subVIs.
Now execute the subVIs one after another using your main VI. Once you executed all four subVI, open them again, try to modify things again.....
Norbert
01-30-2014 07:22 AM - edited 01-30-2014 07:22 AM
The difference is (Correct me if i'm wrong):
The SubVI 1: Always Running
The SubVI 2: The VI goes to idle state when you press the stop button, BUT the reference stays on memory (Static bound)
The SubVI 3: The VI keeps running after the first call (Only unloaded when the Top level.vi goes to idle)
The SubVI 4: The VI goes to idle state when you press the stop button... if the auto-dispose is true, the reference goes away... if not, you need to close the reference manually (Close Reference function) to avoid any memory leak.
01-30-2014 07:36 AM
thanks for your reply.
Jiddu, you are totally right about the difference of the "execution state".
01-30-2014 07:49 AM
Norbert and Jiddu
i still don't understand
Norbert, you said "You configured the call by reference node to a static bound VI. So the node will pre-load the VI to increase execution performance as the VI can never change."
Jiddu, you said "BUT the reference stays on memory (Static bound)"
BUT i have read this http://digital.ni.com/public.nsf/allkb/387EF1BC4762A96C8625713B007E0032
"If you select Reload for Each Call or Load and Retain on First Call, then the VI will be called dynamically when the execution of the code reaches that part of the block diagram. The only difference between these two selections is whether the VI is unloaded from memory immediately after finishing its execution or retained in memory until the calling VI itself closes."
the two options: Reload for Each Call or Load and Retain on First Call, static or dynamical, i am confused.