TooTallNate / node-wav

`Reader` and `Writer` streams for Microsoft WAVE audio files
MIT License
181 stars 37 forks source link

Memory leak #33

Open mifi opened 4 years ago

mifi commented 4 years ago

not sure if i'm doing something wrong, but i'm getting a memory leak when creating many FileWriters (event though ending them properly)

const path = require('path');
const WavFileWriter = require('wav').FileWriter;

const outDir= './audio-rec';

setInterval(() => {
  const fileName = `${new Date().getTime()}.wav`;
  const outPath = path.join(outDir, fileName);
  const writer = new WavFileWriter(outPath, {
    sampleRate: 16000,
    channels: 1
  });
  const buf = Buffer.alloc(10000);
  Buffer.from([255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]).copy(buf);
  writer.write(buf);
  setTimeout(() => writer.end(), 100);
}, 1);
mifi commented 4 years ago

I resorted to use ffmpeg thru child process instead, to avoid the memory leak