LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Always copy function in memory palette

Hi all,

 

I have a question regarding the use of the Always Copy function available in the memory palette and its uses within Labview applications. I have seen it use in VI's such as WDT Number of Waveform Samples DBL in the error case and I am assuming its to overwrite and clear the currently assigned memory in the instance of an error. I was wondering if other had used this function and in what was the remit for doing so? I have put together the example to try and create multiple references of cluster in memory and attempt to modify each instance using a pair of DVR's IPE but have had little success. I would like to stress this is for my understanding of the behaviour of the LV dev environment and not something I attempting to put together for a customer.

 

Always copy.png

 

 

 

 

Many Thanks 

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
0 Kudos
Message 1 of 7
(3,203 Views)

Note: After the copy probes have shown the reference remains the same, also the code will error as there is no need to close the same ref twice in the for loop.

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
0 Kudos
Message 2 of 7
(3,201 Views)

I think that the first misconseption is that the copy copy's the data. in this case it only copys the reference (pointer). next it will in this case not make a difference if the always copy is there or not for the splitting wire will copy the reference no mather what.

 

to copy the data you first need to extract the data from the cluster and copy this and then make a new reference for it.

 

Note: this is to my best of understanding of labview and computer programming in general.  


Learning LabVIEW since January 2013
0 Kudos
Message 3 of 7
(3,186 Views)

Andy,

 

your code makes no sense.

You are using a DVR in order NOT to copy the basic data (cluster). You then copy the reference to the data (DVR) twice as the branch already creates a copy for the reference.

Granted: the compiler should be clever enough to reduce the number of instances of DVRs to two, so you would not waste additional 8 bytes.

 

But so or so, you never create a copy of the original data set, you cluster.

 

Recap:

- Always copy makes no sense for DVRs

- Most branches of wires already create a copy of the data. This depends on the function attached in the branch (e.g. "Array Size" does not create a copy of the data).

- Always copy forces the compiler to create a copy of the data on the wire for the following function(s). This disables compiler optimizations in many aspects.

 

When to use "Always Copy":

If you are not sure if compiler optimizations prevent data copies even if you are confident that you require the data redundantly.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 7
(3,183 Views)

Hi Norbert

 

I was under impression  that compiler will copies data only when you are modifying data in one or more branches.

 

0 Kudos
Message 5 of 7
(3,149 Views)

...which is true for most branches.

You are correct that branches which do not modify the data will not create copies inherently (like "Array Size", "Search 1D Array", "Equal", ....).

But as soon as data is manipulated (like "Increment", "Replace Array Subset", ...) which are used in that different branches will create copies.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 7
(3,143 Views)

I've only seen the Always Copy function used in very rare cases.  And when it does it is to get around a bug in a version of LabVIEW as a work around.  I have never seen this function used in everyday programming.

0 Kudos
Message 7 of 7
(3,123 Views)