LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does passing an array make a copy of the array in memory?

I am using several arrays of clusters in my project.  For several operations I am reading and manipulating 1 index value of the array(s) and than using the replace array subset function to save memory. Speed is somewhat critical as I need to monitor and control 124 stations.

Currently, so as to not have to pass the entire array into the subVi, I am indexing and replacing in the main VI.  Is this saving me any overhead or am I just cluttering up my main VI's block diagram?

Attached is an example file that gives the general idea of my architecture.  I am using multiple loops (user event, software event, and timing - event generation) and queues to maintain data integrity.  Action Engines do seem a possible option, although it will take a considerable amount of rewriting (and rethinking).


0 Kudos
Message 1 of 4
(2,743 Views)
Well I see you're on 8.2, so you can go to Tools -> Profile -> Show buffer allocations. This will place a dot your block diagram every time memory is allocated. It will show you where copies of your data are being created. I can't answer your question with 100% certainty, but this should help you get an idea of how memory is being handled in your program.
Message 2 of 4
(2,736 Views)
Any question who's answer includes the phrase "show buffer" is likely to take a long time to answer. Smiley Very Happy
 
Search on "show buffer" and read through what has alredy been said.
 
Please post back if you still have Q's.
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 4
(2,727 Views)
Marc A's suggestion is really good and should help you out if you have the Profiler tool in LabVIEW.

Regarding your question: LabVIEW compiles VIs using an algorithm commonly known as the inplaceness algorithm. This means that LabVIEW does its best to see when a memory buffer can be reused. If LabVIEW can trace your array from the input of the subVI to the output and see that it doesn't get resized or copied, then you stand a good chance of having LabVIEW not make a copy of that array when passing it into the subVI.

Before I confuse you too much trying to explain it myself, you should check out this well-written help page from the LV documentation. It explains in much better detail what this all means.

Message Edited by Jarrod S. on 04-20-2007 10:33 AM

Jarrod S.
National Instruments
Message 4 of 4
(2,721 Views)