Category: serial-port

SerialPort memory leak in .NET 2.0/3.5

I’m having a problem with the SerialPort class. We’re using multiple serialports in a generic list since we need to connect to multiple devices. This is what our basic code looks like: List<SerialPort> ports = new List<SerialPort>(); private void button1_Click(object sender, EventArgs e) { ports.Add(new SerialPort(“COM6”)); ports.Add(new SerialPort(“COM7”)); ports.Add(new SerialPort(“COM8”)); foreach (SerialPort port in ports) […]