LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Load a dynamic VI and keep it in memory after execution

Solved!
Go to solution

Hi guys,

 

I'm using a strange framework that requires me to follow a set of rules.

 

My problem is this:

 

I have a Main VI (that is compiled into an EXE) that dynamically loads and runs a subVI (the subVI is not compiled into the EXE). The subVI calls a functional global that is only called by dynamic VIs, hence the global is not a dependency of the Main VI and it is not compiled into the EXE either. As you can already see, when I call my dynamic subVI for the first time (say it behaves as a SET function), it will set the functional global; then when the dynamic subVI's execution stops, it deallocates the functional global VI. So then if I call another dynamic subVI as a READ function, it will not retain the information set the by SET subVI.


I am not allowed to make the subVIs or the functional global a dependency of the Main VI and it cannot be compiled into the EXE, so what I have to do is somehow load the dynamic subVI and either keep it in memory even when execution ends, or keep the functional global in memory after first call.

 

Does someone know how I would be able to do this?

 

Help is appreciated,

Drazen

0 Kudos
Message 1 of 5
(3,821 Views)
Solution
Accepted by topic author Drazen

Drazen,

 

When a dynamic VI calls the functional global for the first time, launch another dynamic VI (Holder.vi) which has the functional global as a subVI.  Holder.vi does nothing except wait until Main VI is done calling dynamic VIs.  As long as Holder.vi is in memory, it will also keep the functional global in memory.

 

I have not tried this, but think it will work.  It is a bit awkward, but should have minimal size and CPU resource impact.

 

Lynn

Message 2 of 5
(3,817 Views)

The funny part is that taking a break from looking at LabVIEW code, and taking the time to phrase the question in a simple manner, has made the problem not difficult at all.

 

I believe your solution will work. Let's see what others have to say, maybe there is a simpler solution. I wish there was a check box in VI properties somewhere that had "Keep VI in memory on first call until Application close"

0 Kudos
Message 3 of 5
(3,811 Views)

Lynn, I will try your solution, however it does seem extravagant. I'll update on progress.

 

Does anyone have another suggestion?

 

Thanks!

Drazen

0 Kudos
Message 4 of 5
(3,719 Views)

I've solved this problem, just one thing I ran into and I wanted to mention (the biggest problem) is that my functional global has a case where it initializes a .NET driver. It's important that this .NET driver is initialized in the holder VI and not the first dynamic VI that is called by Main. Since when the first dynamic VI will go out of memory early, it will deallocate the .NET references, even though the shift registers of the global will retain all the other data (strings/variants/etc). Without the .NET references, the functional global is destroyed.

 

Thanks!

Message 5 of 5
(3,615 Views)