node-modbus-rtu
node-modbus-rtu copied to clipboard
Memory leak in Queue
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.
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.
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()