LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

is it feature or bug with reference?

I assumed to get 2 different references but LabVIEW gave the same reference (address 0x9949999B) and values in clusters are the same.

Is it feature or bug?

 

P.s. if Connect.vi will be reentrant than LabVIEW will give 2 different references.

 

Vasilich2004_0-1640207491576.png

 

Download All
0 Kudos
Message 1 of 12
(1,691 Views)

Hi Vasilich,

 

it's a feature…

 

When a VI is not reentrant then only one instance is in memory and will give you the same reference to the very same object.

 

As soon as you set it reentrant multiple copies of that VI will be in memory, eachone providing a reference to its own object…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 12
(1,683 Views)

A Control/Indicator reference is a reference to the front panel object. If you only have 1 object (even though you use it twice), you only have 1 reference.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 12
(1,620 Views)

There 3 Reentrancy options. Middle option is "Shared clone reentrant execution". What would be LabVIEW behavior in this case? 

0 Kudos
Message 4 of 12
(1,199 Views)

Two different ones, usually, but not necessarily, unless you execute both really in parallel. Shared reentrant is still reentrant. The difference is how the reentrant clones are managed.

 

For shared, LabVIEW maintains a pool of clones and whenever the pool is empty it creates a new clone when a new instance is needed. When that instance goes idle (waiting to get called) LabVIEW adds it back to the pool.

 

For fully reentrant, each location gets a copy of a clone allocated at load time.

 

This mean that shared clones can use significantly less memory as LabVIEW only allocates as many as at any moment are really used in parallel. But execution performance can be less predictable as LabVIEW has to check the pool and possibly instantiate a new clone at runtime. Also shared clones can cause data leakage (uninitiated shift register) between executions as an actual instance is not always used in the same spot.

Rolf Kalbermatter
My Blog
Message 5 of 12
(1,185 Views)

@Vasilich2004 wrote:

There 3 Reentrancy options. Middle option is "Shared clone reentrant execution". What would be LabVIEW behavior in this case? 


This blog entry is a decade old, but still quite revalent (only linking to part 1 of 5): https://stravaro.com/lvjournal/2012/02/maintaining-state-1/ 


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 6 of 12
(1,155 Views)

@GerdW wrote:

Hi Vasilich,

 

it's a feature…

 

When a VI is not reentrant then only one instance is in memory and will give you the same reference to the very same object.


And I will expand on why this FEATURE helps you.  How many hairs would you loose if the integer value of a reference wire output from a VI changed each time you called the same vi on the same target in the same context from the same application instance?


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 12
(1,148 Views)

@JÞB wrote:

@GerdW wrote:

Hi Vasilich,

 

it's a feature…

 

When a VI is not reentrant then only one instance is in memory and will give you the same reference to the very same object.


And I will expand on why this FEATURE helps you.  How many hairs would you loose if the integer value of a reference wire output from a VI changed each time you called the same vi on the same target in the same context from the same application instance?


Not sure about your or my hairs in respect to this. 😁 But it would be a major memory hog for sure and a total pitta as you would have to Close each of these references explicitly to not create a huge memory leaker!

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 12
(1,144 Views)

I made test.

"Shared clone reentrant execution" works as "Non-reentrant execution" and doesn't work as "Preallocated clone reentrant exception".

 

So reference doesn't work correctly if it is used as VI output in case of "Non-reentrant execution" and "Shared clone reentrant execution".

Reference works correctly if it is used as VI input.

 

I attached updates files (old Main.vi isn't correct).

I could check myself but I thought that "Shared clone reentrant execution" behaviors could be unstable.

Download All
0 Kudos
Message 9 of 12
(1,090 Views)

Saying that either of these is incorrect is factually incorrect. 😀

 

It actually works exactly as intended! That it is not what you want is another matter. For what you want, shared clones is simply the wrong choice.

 

Shared clones still can work in parallel when this is possible according to dataflow rules, but you don’t get an exclusive copy for every possible call site. As long as there is no effective parallelism, LabVIEW will happily use the same clone for each call site.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 12
(1,086 Views)