03-15-2019 09:04 AM
03-15-2019 09:45 AM
Question.
Why are you worried about memory copies on an array that only has 1000 elements.?
03-15-2019 10:09 AM - edited 03-15-2019 10:14 AM
@RavensFan 已写:
Question.
Why are you worried about memory copies on an array that only has 1000 elements.?
Hi, RavensFan! It's right that the array only contains 1000 elements in the above example and it's unnecessary to worry about the copy.
In the future, however, my program will set the array size and iteration times to be a large number so that I think the memory copies in every loop will degrade the performance and now I am hunting for a reasonable solution to my worries.
03-15-2019 10:18 AM
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.
03-15-2019 10:42 AM
I'm with RavensFan here. The compiler already does a lot to limit array copies. If you are REALLY worried, turn off debugging in your subVIs.
03-15-2019 11:09 AM
@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.
03-15-2019 11:13 AM
@crossrulz 已写:
I'm with RavensFan here. The compiler already does a lot to limit array copies. If you are REALLY worried, turn off debugging in your subVIs.
Thanks,it seems better to believe in the compiler.
03-15-2019 11:28 AM - edited 03-15-2019 11:31 AM
You have several options, but it also all depends how efficient the code of your subVIs is. If you blow it there (e.g. with resizing operations excessive branching, or local variables, all bets are off. I am sure we could give much more targeted advice if we could actually see the various VIs used. What do they do? How different are the subVIs? Could there code be merged into one, e.g. with an addition input giving the desired range?
Still, all this seems pointless for only 1000 elements, but might be useful for gigantic arrays.
If you are concerned, look at allocation dots, and do detailed benchmarking and testing of the various possibilities. This is hard to do right, though. Are you concerned more about memory or execution speed?
03-15-2019 11:36 AM
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.
But depending on the version of LabVIEW the IPE structure may make a copy, read the entire discussion here:
I believe this bug has been quashed in newer versions, 2017 and later??, and the copy does not occur.
mcduff
03-15-2019 11:45 AM
@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]