From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Local variables memory allocate

Hi,

It is well know that Local variables make copies of data buffers. Let's say that I have array indicator that called "Buffer". When I'll create a Local variable, labview immediately create a new buffer associated to the original indicator call "Buffer".

  1. My first question is when I'll create a second copy from the local variable himself -by holding the "Ctrl" key and dragging the local variable from the first local variable, is it true to say that labview creates another buffer array- meaning, a third buffer! (One for the original indicator, one for the first local variable and one for the second variable (All for the same original associated indicator call "Buffer"))?
  2. In this situation, if I'll use the global variable instead of local variable, is it true to say that labview allocate only use two array buffers- one for the first global variable and one for the second duplicated global variable (one array buffer wasn't needed because I don’t have the original indicator because I don’t have block diagram). I read it is always prefer to use global variable instead of local variable from that reason…
  3. Is the same answer applied when the hardware target is FPGA (cRIO- 9075)? Agine, labview will three different buffers for the same "Buffer" indicator and two local variables associated to the same indicator? (in the first situation.

Thanks a lot,

Idan

0 Kudos
Message 1 of 5
(3,771 Views)

Idan,

 

each reading variable is a copy of the value. This holds true for both local and global ones. So each reading variable instance duplicates the original data set.

Doesn't matter what OS you are running, it's always the same.

 

Norbert

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

Local Variables are sometimes necessary, but the Conventional Wisdom is they should be avoided, if possible.  Wires are preferred ...

 

Bob Schor

0 Kudos
Message 3 of 5
(3,716 Views)

Yes, front panel objects (even without any local variables) causes typically three copies of the data in memory. (1) The data allocated by the wire, (2) the transfer buffer, (3) the indicator on the front panel. Since front panel updates are asynchronous, the code only updates the transfer buffer, while the UI thread later updates the control at leasure. If you keep the front panel of a subVI closed, the front panel will typically not even be in memory, greatly reducing the memory footprint. Certain code elements (e.g. proerty nodes) force the front panel to be in memory, so avoid those!

 

Many times the data (e.g. halfway through a calculation) is uninteresting to the user, so it is important to only create front panel objects for the intersting stuff. One very efficient way is to keep large shared datasets is by using a data value references.

 

Some easy reading about memory and LabVIEW.

 

Message 4 of 5
(3,707 Views)

Thanks for pointing out this reference (in the LabVIEW Help) on Memory usage.  I hadn't read it, and there's a lot of stuff in there I didn't know (as well as I thought I did).

 

BS

0 Kudos
Message 5 of 5
(3,674 Views)