LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster buffer allocation in case structure

Hi

 

There is a buffer allocation of the cluster on the input tunnel of the case structure.

Why is this happening, and more important, how can I avoid it?

buffer_case.png

0 Kudos
Message 1 of 5
(4,781 Views)

It's happening because the Case Structure needs a copy of the cluster to operate on regardless of how it's branched externally. 

 

I don't have LV on this PC.  But, depending on what your logic is in the False case, you likely can replace the structure entirely with something else if you're worried about the allocation.  For example, what's shown here can be replaced with a Select.

 

If you get to a place where your buffer allocations are causing harm, you can potentially take a look at DVRs.  Although, I'd be careful with those.  They will benefit you in the way they'll only ever duplicate a pointer instead of the entire cluster.  But, they can also introduce race conditions if you're not handling them well.

0 Kudos
Message 2 of 5
(4,742 Views)

You might try the In-Place Element structure (which, if the name is to be believed, operates "in place", without allocating another copy).  Of course, another copy will be needed for the Output variable.  Note that I simplified the Case Statement -- "if input is True, output is False, while if input is False, output is False" is equivalent to "output is False".

Cluster In-Place.png

Bob Schor 

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

 

That isn't a buffer allocation. It's a terminal that's been configured to automatically wire the data through the structure. This is used when you might add a case later but need to have the cluster wired through in all cases.

If you right-click the output terminal you can "clear" the link.

Create and Wire Unwired Cases1.pngCreate and Wire Unwired Cases 2.PNG

Message 4 of 5
(4,725 Views)

While we are looking at simplification, why not just remove all structures.  Just use the bundle and input the False if both cases update it to False?

0 Kudos
Message 5 of 5
(4,689 Views)