LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP and memory

I am using TCP-IP to transfert, in a loop, the result of data acquisition from a target using LabVIEW-RT to a host system.
As the size of the buffer is very important for the performance of the TCP-IP transfer, I have choiced to use a fixed size for the buffer (1024 bytes). For this reason, my buffer includes at least 3 parts : the header, the data and the padding.
At this time, I am using the "cast" function to convert the data following by the "concatenate string" function to build the TCP-IP string. But I refer to some documents about the memory management, this sequence induces memory allocation and copy in my loop.

Do you have ideas to avoid the memory allocation and copy in the loop ? If I know how I can do with an array (using the "replace arr
ay subset" with a preallocated array), I don't know how I can do with a string.

Thanks,
Hubert
0 Kudos
Message 1 of 3
(2,966 Views)
Hi Hubert,

It is generally a bad idea to do TCP/IP inside a time critical loop. You can not maintain determinism if you do so. I would recomend using queues or LV2 style globals to pass the data to a parallel, non-time-critical loop to do the TCP/IP work.

That having been said, I will address your question.

You could use an array of U8's and do the replace array elements using U8's. When ready to transmit, cast the array of bytes to a string and you are off.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 3
(2,966 Views)
Thanks for the information.
I know the determinism problem with TCP-IP but I need to send the data to another system in real-time and, at this time, I don't have another solution than ethernet (it is a point to point ethernet link).

Hubert
0 Kudos
Message 3 of 3
(2,966 Views)