LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Revising a buffer Action Engine (Data storage/Graph curves read out)

Solved!
Go to solution
Solution
Accepted by Blokk

@proland1121 wrote:

from 2009... http://digital.ni.com/public.nsf/allkb/F3FB3A32B51BF33E8625763100704136

 

Additionally, the Build array function carries out a memory copy operation, which can slow you down.

Excerpt from:  http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/vi_memory_usage/

"If the size of an output is different from the size of an input, the output does not reuse the input data buffer. This is the case for functions such as Build Array, Concatenate Strings, and Array Subset, which increase or decrease the size of an array or string. When working with arrays and strings, avoid constantly using these functions, because your program uses more data memory and executes more slowly because it is constantly copying data"

 

Basically, each build array operation attempts to first copy the data from one space in memory to another.  This is the step vulnerable to "out of memory error".  I may be wrong about it needing to be contiguous in regards to this error.

 


Just to clarify that one point.

 

The Build array MAY do a memory copy. LV is pretty smart with managing memory and will attempt to avoid the costly memory allocation if it can. The numbers may have changed since I was studying this operation but at an early date (about LV 6.1) LV would allocate maybe 1K to an array in a SR to start. It would keep filling in that memory until it ran out and then when it out-grew the allocation, would allocate a buffer twice as large. move the old data to the new buffer and then start working in that contiguous memory space. each time a "malloc" was required, the buffer doubled in size.

 

modern version of LV have a;

 

Tools >>> Profile >>>> Profile Buffer Allocations

 

That will let you monitor the buffers.

 

Now I am going to repeat myself from above.

 

Multiple queues can be used as buffers and the various queues do not require contiguous memory. They operate "in-place" so transferring an update from DAQ to display requires only moving handle from one thread to another and the data can sit just where it was when it was queued up.

 

Now if you still want to read more, check the links in this Tag Cloud for LabVIEW_Performance. Included in that collection are post from Greg McKaskle who (when last I checked) was a Chief Architect for LabVIEW and used to answer questions here in this forum... right up to when LV 7.0 was scheduled to be released and management had him concentrate on developing instead of supporting.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 21 of 23
(728 Views)

Thanks for the lots of info! I really started to think, in my recent task, I will just use a Queue along with a Lossy Enqueue (and every second use a "Get Queue Status" to retrieve the whole 2D array). Hmm, now I wonder how fast this Get Queue Status function? I hope it has the same performance as the "Dequeue Element" one...I will test this approach next week!

 

About the Build Array function. To clarify, I never run our applications from the IDE, I always make a build, and I run the EXE on a PC where LV RTE (plus some required things like VISA RTE) is installed.

Question: is there any difference in memory handling regarding to the IDE and the RTE?

 

I never saw a single crash/error in my app, and it runs with this "build array" approach since ~summer of 2017. And the used memory never grows above ~250 Mbyte under Windows. I had a crash since then, but it was due to some USB3.0 / cDAQ incompatibility (replacing the cheap quality and too long USB cable with the official short NI cable, plus moving the cDAQ to a USB2.0 port on the laptop seems to solved the issue)...

0 Kudos
Message 22 of 23
(722 Views)

@Blokk wrote:

...

Question: is there any difference in memory handling regarding to the IDE and the RTE?

 

...


No differences that I know of unless you muck with it or are splitting hairs.

 

"Retain Wire Value", debugging enabled, sub-VIs with  open FPs, undo-buffers... can demand more memory.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 23 of 23
(717 Views)