LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Intensity Rankings

What is the least memory intensive (or could someone rank memory intensities) between a feedback node, a shift register, a local variable, a global variable, and a property node.

My understanding is that  property nodes are much more memory intensive than local variable, but how does everything else compare?

Or another way of putting it, is if I could use any of the 5 mentioned items, which one should I use to use the least memory.

Thanks for the info,

-GuruDoo

0 Kudos
Message 1 of 9
(4,691 Views)
Here's something to start with.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 9
(4,676 Views)

There shouldn't be that much difference in memory usage between any of them.  (Are you actually interested in performance, i.e. how fast the code runs?)

 

A global variable would probably have the largest memory footprint as it actually is a VI underneath.  Feedback nodes and shift registers should be similar in memory usage.  Local variables and a wire coming out of a value property node should be similar in memory as well as they are additional copies of a datatype.

 

Overall, the memory differences between them would be inconsequential for all but the largest datasets.

0 Kudos
Message 3 of 9
(4,674 Views)

Is this an academic question or are you having actual performance problems? Memory use is only one of the factors to consider, but the actual number of datacopies in memory aso depend on other coding habits. If you branch a wire the wrong way, (bang!) there another data copy without any of the things you mentioned! Memory use can be controlled by other things such a good choice of data representation. If you have 8 bits worth of data, don't convert it to EXT for some simple math. If you operate on numeric data as boolean arrays, you are using 8x more memory than needed.

 

Fortunately we have a tool to show buffer allocations. Newer LabVIEW versions also have the "in place" structure that can sometimes help. 

 

In any case, these questions are typically only important if you are dealing with large data structures.

 

Can you tell us a bit more on what you are trying to do. Why do you need any of these ?? 😉 

 

Feedback nodes and shift registers are typically pretty good. Local and global variables and value property nodes force extra data copies in memory. value property nodes also force synchronous execution, which can be expensive even if the memory use is OK. Again, if you resize an array, you create another data copy, no matter what you use. Best is fixed size data structures in a shift register or feedback node.

 

Also don't place controls and indicator in inner loops unless it is really required.

 

It always helps if you do a few simple sample programs using the various techniques and do some benchmarking.

 

Here's an old such result, showing that shift registers can be ~6000 times faster than value properties in some cases, because no terminals need to be inside the loop. Local variables and property nodes must be inside the loop. Value properties slowest. 😄

Message 4 of 9
(4,672 Views)

Hi GuruDoo,

 

Yes, as the others said, more information about what the actual core of your question is would helpful to provide you with a solution.

Jeff | LabVIEW Software Engineer
0 Kudos
Message 5 of 9
(4,637 Views)

This is mostly an academic question, but I am applying it to an application.  Say I have 2 timed for loops.
  The first is reading data from a DAQ card and running at 50ms intervals.
  The second is controlling a motor, by taking some of the data from the DAQ card and using it as feedback for a calcuation to determine the new motor output.  The second loop runs at 100ms.
  In the second loop, I want to display (on the front panel) the min and max angles the motor has traveled, which is updating as the motor moves. 
Currently, I have a local variable referring to the min and max angles in the second loop, which allow for the updating to take place.
To do the min max comparison between the new data and the existing data I'm using a feedback node.
Conversly, it could be structured with a shift register, property node, local variables, or global variables.
I just wanted to determine which way is best to structure the code. 

Overall, my program is quite large, so I'm trying to save any memory where possible.
Thanks for the info.  All of it has been a great help so far.
-GuruDoo

0 Kudos
Message 6 of 9
(4,625 Views)

It is important to be aware of other kind of memory abuse. I found one good example here http://forums.ni.com/ni/board/message?board.id=170&message.id=406823#M406823. Important question is how often do I need to update my information and what do I need to show. For example it is pretty nonsense to show 700K point in a chart small chart if you not are looking for a detailed view. It is also a dumb idea to update indicators to often. This will not increase your memory consumption, but it may slow down your overall system performance. As an example. Say you sample a signal with 1KHz, and chart the result live in a waveform chart. You could of course update the chart in the same rate. But the human eye will never tell the difference if you update chart in say 25 times pr second with 40 samples each time. If i am not wrong, so is 24 frames pr second the motion picture frame rate



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 7 of 9
(4,620 Views)

Take a look at this thread where we talk about different methods of sharing a single value to multiple threads. We eventually got R&D to step in and muddy the waters but eventually the mud cleared.

 

This tag cloud contains a collection of links related to LabVIEW Performance.

 

Memory ranking best to worse

 

In-place (either an Action engine or a queue depending on how well they are written).

Wire on diagram

Control terminal

Local (waring mutliple copies requires a buffer for each but are optimized for performance)

Globals (memory copies for each instnace and subject to race conditions)

Property node value ( need to invoke OS to do a thread swap to the user interface thread)

 

Chime in if I got one of those wrong!

 

Have fun,

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 9
(4,618 Views)

Some more info was posted by darren on the blog:

 

http://labviewartisan.blogspot.com/2009/03/why-are-you-still-using-loops-in-your.html

 

Felix

0 Kudos
Message 9 of 9
(4,590 Views)