serialport/node-serialport

Big memory leak when putting the port into flowing mode

Opened this issue · 0 comments

SerialPort Version

12.0.0

Node Version

16.20.2

Electron Version

No response

Platform

Windows

Architecture

x64

Hardware or chipset of serialport

custom usb serial program

What steps will reproduce the bug?

I have a USB to serial device that is producing 2MB/s of data. I'm reading it with the following program

const { SerialPort } = require('serialport')
let port = new SerialPort({
    path: "COM15",
    baudRate: 57600,
})
port.on('open', () => {
})
port.on('data', (data) => {
})

This causes the node process to steadily increase memory usage (as seen in Window's tasks manager active private working set). It jumps very quickly to 400Mb but if leaved to run it keeps going up, I have stopped it around using 2GB of memory.

I have instead run chrome's memory profiler but it doesn't report a big heap so I assume this is leaking memory in the C++ side not in the javascript side.

if I don't call

port.on('data', (data) => {
})

I don't see the increased memory usage.