qeled / discordie

Predictable JavaScript abstractions for Discord API.
https://qeled.github.io/discordie/
BSD 2-Clause "Simplified" License
190 stars 45 forks source link

Cannot enlarge memory arrays ERROR #65

Open Mochlate opened 7 years ago

Mochlate commented 7 years ago

I am getting this error and I have no idea where its coming from.

2017-01-16 17_43_39-logs viewer - my first project

qeled commented 7 years ago

How many voice connections do you have? You shouldn't run into this error with internal encoder until maybe 100-150 streams, and if so - I highly suggest cleaning up inactive connections or not using pcm format with FFmpeg at all as it has too much performance overhead.

If you do have very small amount of connections spawned though, it may be a memory leak, but I highly doubt that this is the case.

Mochlate commented 7 years ago

It appears to be happening when .VoiceConnections is only of length 10

Mochlate commented 7 years ago

@qeled how can I begin to figure out what might be causing this problem. I can confirm that it happens below 20 people streaming audio at the same time.

qeled commented 7 years ago

I've added an option to enable encoding using a native module through the FFmpeg player in the commit above. Do an npm install node-opus and add { ..., format: "pcm", encoderEngine: "native" } to the options.

But again, I don't recommend using the pcm format option and doing audio transcoding in the node process, you should be using { ..., format: "opus" } instead as this will eliminate the biggest bottleneck you are currently facing.

Mochlate commented 7 years ago

I tried using opus and it did not seem to reduce cpu or ram usage at all

qeled commented 7 years ago

If you have preencoded opus audio, optimize it further by using WebmOpusPlayer/OggOpusPlayer instead of transcoding every time through FFmpegEncoder.

Though those only accept node stream objects as source (like HTTP(S) responses, file streams, etc.), and you have to implement networking/IO handling yourself if you need something like connection resuming.