You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I create enough midi.input() instances, I eventually run out of ALSA resources on Linux and my program terminates.
For example, running the following program:
var midi = require("midi");
for (var i = 0; i < 100; i++) {
new midi.input();
}
process.exit();
Results in:
ALSA lib seq_hw.c:457:(snd_seq_hw_open) open /dev/snd/seq failed: Cannot allocate memory
MidiInAlsa::initialize: error creating ALSA sequencer client object.
terminate called after throwing an instance of 'RtMidiError'
what(): MidiInAlsa::initialize: error creating ALSA sequencer client object.
Aborted
I think what is happening is that while the ~NodeMidiInput() destructor deletes the RtMidiIn instance that it creates, I believe that there is no guarantee of when the destructor will get called by the garbage collector.
To test this theory, I've created a fork of node-midi that adds a function to explicitly delete the RtMidiIn instance:
With this version, I'm able to create lots of midi.input() instances as long as I explicitly delete the associated RtMidiIn object when it's no longer needed:
var midi = require("midi");
for (var i = 0; i < 10000; i++) {
var midiInput = new midi.input();
midiInput.release();
}
process.exit();
The text was updated successfully, but these errors were encountered:
simonbates
added a commit
to sbates-idrc/Flocking
that referenced
this issue
Nov 18, 2016
On ALSA Linux, node-midi input and output objects hold onto resources that
eventually may run out causing the process to terminate. This change to
Flocking makes use of a work around added to a fork of node-midi which
adds a new explicit "release()" method to free the underlying RtMidi (and
corresponding ALSA) resources.
See: justinlatimer/node-midi#118
If I create enough
midi.input()
instances, I eventually run out of ALSA resources on Linux and my program terminates.For example, running the following program:
Results in:
I think what is happening is that while the
~NodeMidiInput()
destructor deletes theRtMidiIn
instance that it creates, I believe that there is no guarantee of when the destructor will get called by the garbage collector.To test this theory, I've created a fork of node-midi that adds a function to explicitly delete the
RtMidiIn
instance:master...simonbates:release-rtmidi
With this version, I'm able to create lots of
midi.input()
instances as long as I explicitly delete the associatedRtMidiIn
object when it's no longer needed:The text was updated successfully, but these errors were encountered: