08-01-2013 10:53 PM - edited 08-01-2013 11:09 PM
I load a reentrant vi dynamically (about 10 copies). The vi is about 233kb on disk, 1000kb in memory. I've noticed as I've been adding more code to this vi, my Close Reference is taking longer and longer. Any idea why this would occur? There are many subvi's included in this vi. I assume when calling it by reference, it is loading the main vi and all of its subvis (all reentrant as well) into memory. And, in my case, 10 of these total.
What is it really doing when "Closing a reference"? Housekeeping? Any alternatives?
08-01-2013 11:19 PM
An alternative way is you can enable the "Auto Dispose Reference" when you call the VI dynamically, this will close the reference automatically once it is done.
08-01-2013 11:27 PM
Tried that. What ends up happening is the VI just sits there waiting to exit (I presume it is internally closing all 10 instances). I retrieved the Metrics:Block Diagram size, and it reported 1123025. Not sure if this is in bytes, but if so, thats rather large and probably includes all the clones from subvis.
Correct me if I'm wrong here, but if you have a main VI with 5 states (size of 100kb), each state calling a different reentrant VI that is 1MB in size, would the total memory allocation for loading this VI be 100kb+( 5 x 1MB ) = 5,000,100 bytes (more or less)?
If so, than this may be my issue. I may have to rethink the architecture here.
08-02-2013 07:40 AM
You are missing a key piece of information. What form of reentrant are you using? Preallocate Clones or Shared Clones? The preallocate will use a lot more memory. The shared clones will reuse the clones whenever possible. If you are saving state information in these subVIs, then you pretty much need to use preallocate clones.
Do you have large arrays? That is when I have ran into problems due to LabVIEW releasing all of the memory those arrays were using.
08-02-2013 09:16 AM
Thanks for the response. Yes they are shared clones. I don't need to save state information.
There are no arrays in these subvis. I do load some global arrays, but they start off initialized as empty. I understand the size of the vi and am not contesting that portion. What I noticed is once compiled to an executable, the references close at a much quicker speed.
Seems to be related to the development environment. I'm also on 2010 SP1. Not sure if this matters.