Closed colinbdclark closed 5 years ago
As a workaround, I have created a fork of node-midi that adds a method to the input and output objects to explicitly free the underlying RtMidi objects. I have also made some changes to Flocking to perform this explicit freeing whenever the ports are refreshed.
See also:
Flocking no longer directly supports Node.js, so I'm closing this issue.
The implementation of Flocking's MIDI support in Node.js is excessively eager about creating node-midi
MIDIIn
andMIDIOut
objects. In particular, a node-midimidi.input
ormidi.output
instance is created whenever aMIDIPort
object is instantiated.The issue here is that
MIDIPort
s are created anew each time a user enumerates the list of MIDI ports connected to aflock.midi.system
using therefreshPorts()
invoker. However, @simonbates—who is working on a polling feature that regularly checks to see if the list of ports has changed—has discovered that ALSA will crash if too many port instances are created, since node-midi doesn't provide any means for releasing the underlying RtMidi and ALSA resources it creates.Given this reality on Linux, it seems that Flocking needs to be much lazier about when it actually allocates an underlying
MIDIIn
orMIDIOut
instances—this should be deferred until theMIDIPort
is actually opened.This issue will be addressed in the new flocking-midi library.