node-modbus-rtu icon indicating copy to clipboard operation
node-modbus-rtu copied to clipboard

Memory leak in Queue

Open vasyas opened this issue 8 years ago • 2 comments

It looks like there is memory leak around Queue management. When the port is closed, Queue should be stopped (mether Queue.stop called). But there's no code for that.

This leads to Queue and all references objects (including serial helper and serial port and other objects via closures) to be retained during GC.

vasyas avatar Nov 17 '17 20:11 vasyas

Hi, good catch! Actually in my app I never close the connection and therefore I havent faced this issue.

Please feel free to create pull request, because I can manage it only when have a time for that.

timofei-iatsenko avatar Nov 17 '17 20:11 timofei-iatsenko

Sure, I understand.

A quick workaround for now is to cleanup queue on closing port:

const modbus = new ModbusMaster(port)
...
// when port is closed
modbus.serial.queue.stop()

vasyas avatar Nov 18 '17 15:11 vasyas