◐ Shell
clean mode source ↗

Potential memory leak in UDP

  • Version: 4.4.2
  • Platform: Linux (Ubuntu Server 8 - Jessie), kernel 3.16
  • Subsystem: dgram.js

UDP sockets seem to have a memory leak. Seems that it's not the first time it had that, so it feels to me that it might be a regression. The following test code reproduces it:

const Crypto = require('crypto');
const Dgram = require('dgram');

let socket = Dgram.createSocket('udp4');

setInterval(() => {
  for (let i = 0; i < 30; i++) {
    socket.send(Crypto.randomBytes(50), 0, 50, 8125, 'example.org');
  }
}, 10);

Memory grows approximately at a rate of 1 MB/s in my machine. I assume that a UDP socket should just send the data (no matter if no one is listening on the other side), so there should not be this huge memory consumption.