Memory leak in modbus flow

I working on a Modbus TCP flow .
When the network is slow Node-red is consuming more and more memory .

if there a chance for Queue formation in these nodes and it consumes more memory?.

What is the best way to find memory leak ?.
I took heapdump at different times ,is there any other way ?

That usually means that you are not able to process messages at the speed they are coming in. I think you need to give us a bit more information about what your flow consists of. Also, which network are you talking about? Are you getting modbus data faster than you are able to process it?

We have a linux machine where Node-red is running and it connects to Modbus TCP devices.
The linux machine we can see many reconnect attempt in netstat .

Seems NR hold the handles to these and it takes more and more memory .
When we restart NR everything is fine for some time .

I the devices are not connecting quickly or bad network ,memory leak is quite fast .
'modbus-client is used in NR with timeout 3000 and Reconnect 5000.

The chances are that the issue is in the contrib node you are using. Have you opened an issue on the nodes github page to highlight your findings to the nodes author?

After deep investigation ,we found out that memory leak happens only when there is a bad TCP connectivity .Seems request to connect get accumulated and finally node-red fails.

If there is no connection issue everything is fine.
Will check with author too.

Are you asking the node to do things quicker than it is able to handle them so the requests build up?

The node normally connect to modbus and connectivity is correct everything works.
But if TCP connection fails ,we still push messges to the node and it try for connection .

Multiples tries accumulate memory .It does not forget old try I believe.

Are you waiting for it to tell you that it has failed or succeeded before sending the next request? Or do you think it is that it does not release some memory when it fails?

I am not waiting for it to tell ,my intention is if connection succeed the message has to go .
If connection fails ,it should forget the previous try when we try to connect again.

It may be difficult (or even impossible) for the node to do that if it is waiting for a reply from the network stack.

the node may well be retrying to create a connection without cleaning up the old attempt first...

1 Like

Thanks for this thread. Just diagnosed similar issue and came to your thread for confirmation. Much appreciated. Be nice to see a fix.

My invertor was not responding to the frequency in which i was trying to connect. I reduced the number of connection request and solved the problem.

1 Like

Cool.

I've stripped down my logic to only poll the device (digital out only) to read the states after there's been a change (plus a few extra times for latency/double checks).

Seems a lot better.