LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficient memory usage for transferring data within the project

The question I have is about efficient memory usage regarding transferring and storing the data within the project. I have multiplex (interleaved) data which contains information for eight channels and LabVIEW project receives this data from client with TCP. I have to separate these data into channels in order to process. There, I have two ideas regarding the method the data will be carried throughout the project, but I am not sure which one is more efficient in terms of memory.

  1. The data can be read from TCP without separating them into channels and this array will be put into queue to pass the data to the VI to process it and the channel separation will be in the processing part. In this way, the queue only carries an array within the queue.
  2. The data can be read from TCP by separating them into channels and this gives eight arrays, which I put into cluster and then into the queue. In this way, the queue carries eight arrays, the length of the arrays is eight time less than the first method but the array number increases eight times.

I would like to ask which method seems more efficient in terms of memory. Thank you beforehand.

0 Kudos
Message 1 of 7
(1,757 Views)

Hi Esra,

 


@Esra_ wrote:

I would like to ask which method seems more efficient in terms of memory.


Your first option receives an array of data and puts it into a queue.

The 2nd option receives the very same array of data, splits into 8 smaller arrays, bundles those into a cluster and stuffs that cluster into the queue.

 

IMHO the first option is less CPU/memory demanding…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(1,755 Views)

Memory efficient from which perspective?  Overall, I think you will be basically using the same amount of memory.  My suggestion is to keep it simple and go with Option 1.  From there, it really depends on what you are trying to do with the data.  I can image making the queue element be an array containing 8 elements (1 sample for each channel), which puts a little more processing on your TCP read code, but easier to understand at the overall level.  Or if you need to process a bunch of data at once, you just enqueue the entire read data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 7
(1,730 Views)

From a standpoint of encapsulation, I'd lean toward crossrulz' latter comment.  Let the knowledge and work of parsing out the TCP string reside in the TCP client code.  Translate from string to numerics with 1 sample per channel *before* enqueuing.  Then the other part of your app receives meaningful numeric data and doesn't need to know details of the TCP message protocol in order to do the parsing itself.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 7
(1,722 Views)

In terms of the two methods, I think they will consume about the same amount of memory. Kind of outside the scope of what you asked, but IMO your time would be better spent thinking about the best data type for your data. For example, if you can get by with the accuracy of SGL data instead of DBL, that cuts your memory consumption in half right there.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 5 of 7
(1,721 Views)

Yes, I am converting string to byte array before enqueuing the data. 

0 Kudos
Message 6 of 7
(1,610 Views)

@Esra_ wrote:

Yes, I am converting string to byte array before enqueuing the data. 


There's only a semantic difference between a string and a byte array because a string is a byte array.  You don't save any memory, if that's the reason for doing this.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 7
(1,595 Views)