Errors -314230 & -314320: Memory Leak When Using Network Streams in LabVIEW

Updated Sep 14, 2023

Reported In

Software

  • LabVIEW

Issue Details

I'm using the Network Streams Functions to transfer data across a network, but there appears to be a memory leak and I can see the RAM usage gradually increasing over time on one or both of my endpoints. Eventually, if I leave my code running, communication between my systems is interrupted and I get one or both of the following error messages:

Error -314320 occurred at Write Single Element to Stream in Simple Networks Streams - Host.vi

Possible reason(s):

LabVIEW: (Hex 0xFFFB3430) LabVIEW could not create the remote endpoint because the computer that hosts the endpoint ran out of memory.

 
error -314320.png
Error -314230 occurred at Create Network Stream Writer Endpoint in Simple Network Streams - Host.vi

Possible reason(s):

LabVIEW: (Hex 0xFFFB348A) LabVIEW could not create the local endpoint because the computer that hosts the endpoint ran out of memory.

error -314230.png

Solution

Memory leaks commonly refer to situations when memory usage will increase until the system runs out of memory. To prevent this, in LabVIEW 2011 and earlier, you should specify the size of the input and output buffers. This will limit the maximum size of the buffers and assuming that the size you specify does not exceed the available RAM, you will not run out of memory. To calculate the required RAM for your network stream application, you can use the following expression: RAM = Total of Elements Being Sent/Received × Data Type (bits) x Size of the Buffer.

To set the size, wire a constant to the writer buffer size and reader buffer size inputs of the Create Network Stream Writer Endpoint.vi and Create Network Stream Reader Endpoint.vi respectively. These became required inputs starting in LabVIEW 2012.
 
 

Additional Information

Some fluctuation in memory usage is expected when using non-scalar data types such as clusters, waveforms, images, or variants. This is because the size of these data types can vary during runtime.

To compensate for this fluctuation, the buffer does not contain the elements but rather pointers to the actual data. Memory for each element is then allocated dynamically at runtime as elements are written to the buffer. The dynamic allocation of memory can cause the CPU to work much harder than it needs and so it can be more efficient to use scalar data types like numerics to transfer your data instead of the non-scalar data types. 

For example, it is better to use an array of doubles instead of a waveform. With the Array of Doubles, you can use the Write Multiple Elements to Stream and Read Multiple Elements From Stream functions to transfer your data across the network as in the images below. The use of the scalar values removes the need to dynamically allocate memory freeing the CPU from having to perform that operation. This decreases CPU usage while maintaining the same data rate.