From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reference loss when created by Dynamic VI

Hello,

 

I am actualy designing a program using a Model-View-Presenter Template.

Views and presenters are contretized by dynamic lauched Vis.

Models are shared between Presenters using LV References.

 

Main models are instantiated by the main presenter. Others models, that might belong to main models can be instantiated by sub presenter within sub presenter thread.

 

Using execution-trace I noticed that all references created in sub presenter thread are destroyed when thread stops.

 

That is very annoying because the aim of sub presenters is to modifiy and eventualy create sub models. And if sub models can not be reused after sub presenter is destroyed, my design pattern will never work.

 

Does anybody ever met this situation?

Is there any way to ask labview runtime to keep valid references created in dynamic launched VI when this one stops?

 

thanx for answer.

 

Pierre

0 Kudos
Message 1 of 7
(2,643 Views)

Generally, LV automatically destroys a reference when the hierarchy it was created in goes idle. The hierarchy is determined by the top level VI, which is either a VI where you press the run arrow or a VI you run using the Run VI method (which is what happens in your case). Today there is no way of disabling this behavior. Hopefully in the future NI will change it so that references are only destroyed when no one actually uses them.

 

The only way to handle this today is to make sure the reference is first created in a hierarchy which will stay in memory. This can be either your main hierarchy or a daemon which you call in the beginning and has the task of creating the references.


___________________
Try to take over the world!
0 Kudos
Message 2 of 7
(2,635 Views)

Cross-post: http://lavag.org/topic/14891-reference-loss/


___________________
Try to take over the world!
0 Kudos
Message 3 of 7
(2,632 Views)

Thanx,

 

I tried with a thread that is specialized in model reference creation. that looks that way :

 

 

Size of Queue is important because creations can be concurents.

 

 

0 Kudos
Message 4 of 7
(2,623 Views)

And reference creation goes that way :

 

 

Then I have to cast reference for specific models.

 

Now it's time to make a f****** script to automaticaly modify my 50 model classes already created.

 

thanx for you help.

0 Kudos
Message 5 of 7
(2,614 Views)

For named queues the problem is considerably simpler, because each time you call Obtain Queue you get a different reference and the queue itself is only destroyed if all those references are closed, so the order of who obtains the reference first doesn't matter as long as there is always at least one reference to the queue in memory.


___________________
Try to take over the world!
0 Kudos
Message 6 of 7
(2,601 Views)

I know, but, queue referenced don't support automatic down casting on Vi connectors... And both mecanism have allmost same performances. That's why I have decided to choose LV References.

0 Kudos
Message 7 of 7
(2,587 Views)