LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Close Reference to VI takes a long time

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?

0 Kudos
Message 1 of 5
(2,857 Views)

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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 5
(2,847 Views)

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.  

0 Kudos
Message 3 of 5
(2,840 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(2,810 Views)

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.

0 Kudos
Message 5 of 5
(2,801 Views)