‎07-14-2020 07:46 AM
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.
I would like to ask which method seems more efficient in terms of memory. Thank you beforehand.
‎07-14-2020 07:51 AM
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…
‎07-14-2020 08:35 AM
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.
‎07-14-2020 08:47 AM - edited ‎07-14-2020 08:48 AM
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
‎07-14-2020 08:48 AM
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.
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.
‎07-23-2020 09:13 AM
Yes, I am converting string to byte array before enqueuing the data.
‎07-23-2020 09:26 AM
@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.