LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do to avoid unnecessary copy of the array?

Solved!
Go to solution

@altenbach wrote:

@mcduff wrote:

Depending on what version of LabVIEW you are using, you can use the IPE structure with the array split primitive to modify a subset of your array inline without any copies.


As I mentioned, this won't work here because the ranges overlap:

[0..199], [150..799], [750..999]

 


I did not see your reply while typing mine, sorry. I did not look at the indices either, I was thinking of a sequential process like the OP posted.

 

mcduff

 

 

0 Kudos
Message 11 of 13
(930 Views)
Solution
Accepted by Heartnode

@Heartnode wrote:


Thanks,it seems better to believe in the compiler.


Mostly yeah.  I mean I try not to put too much faith in the compiler, but it has matured very well over the years and NI has had lots of focus on run-time applications making sure that things are done in as efficient way as possible given the code the developer wrote.  There is only so much it can do of course and sometimes badly written code really is going to force the compiler to make copies.

 

On the other hand there are times when the compiler is too aggressive and will do things that causes the application to not behave in the way it was written.  These are somewhat rare, and when they do NI should be involved with a small test case to help eliminate the issue.

 

My advice on this topic is just to write code as well as you can, and inline those VIs when you can like Altenbach said.  Let the compiler do the rest, and if you start seeing issues then investigate how to make things better.  I've spent too much time trying to optimize some chunk of code only to find I added so much complexity for saving a few clock cycles that it is harder to manage.

Message 12 of 13
(929 Views)

@Heartnode wrote:

@RavensFan  已写:

What exactly are you doing to the arrays when you modify them?  I would use In Place Element Structure inside the subVI's.  But I don't think you really need to do that.  LabVIEW is pretty good about managing memory as long as you aren't doing anything crazy.  I feel like you are trying to solve a problem that doesn't exist.


Thank you for your advise. I usually use Replace-Subset function and sometimes In-Place structure inside the subVIs. Maybe I am just curious about how LabVIEW handles the memory and data passes.


About 13 years ago one of the Chief Architect of LabVIEW taught us about that in what is now known as the "Clear as Mud thread".

 

It is good read and answers your question.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 13 of 13
(917 Views)