TooTallNate/node-speaker

Memory Leak

Closed this issue · 1 comments

boedy commented

I'm experiencing a memory leak on my raspberry PI using node-speaker. Running the code copied from @LinusU in this PR #22) will slowly consume all available memory:

var Speaker = require('speaker');
var RandStream = require('randstream');

var s = new Speaker();
var firehose = new RandStream();
firehose.pipe(s);

I'm not able to pinpoint the error, but based on my heap profiles a lot of object are remaining behind, which are not being cleaned by the GC. See a screenshot of that below:

Screenshot 2020-10-30 at 17 39 28

Tested on:
Raspberry PI 3B+
NodeJS (v8.11.4)

boedy commented

Turns out this is a bug in the node-addon-api for node versions prior to v8.12. See nodejs/node-addon-api#237. For people affected this issue it's recommended you upgrade.

This line was causing the issue: https://github.com/TooTallNate/node-speaker/blob/master/src/binding.c#L122

As for other memory leaks. #144 still needs to be merged as it is causing leaks for all node versions.