Potential Memory Leak
A potential memory leak issue was reported to me by a user of the WEBMIDI.js library. This library uses jzz in the Node.js environment to emulate the Web MIDI API.
Based on the info reported by the user, I ran the following script to troubleshoot the problem:
const express = require('express');
const navigator = require('jzz');
// jzz
navigator.requestMIDIAccess({sysex: true}).then(
() => console.log("MIDI Started"),
() => console.log("MIDI Failed"),
);
// express
const app = express();
app.post('/test', (req, res) => {
res.json({ success: `Yeah!` });
});
app.use(express.json());
app.listen(3001, () => console.log("Express Listening..."));
After 2 hours, memory usage went from 19MB to 40MB. Is it possible that there is a memory leak in jzz ?
Thank you for reporting that!
If the problem is Mac-specific, it should be in the jazz-midi module: https://github.com/jazz-soft/jazz-midi
The related code is in the midi subdirectory.
I'll try to investigate. You can also take a look with fresh eyes.
Just wonder why MIDI is used on the server side?? There can be some workarounds unless the server actually needs to connect to the MIDI devices.
Just wonder why MIDI is used on the server side??
I believe he uses express locally only.
However, I could totally see a scenario where local devices could be accessed remotely. For instance, you could create an interactive installation where remote users can trigger sounds in a museum space.
If the problem is Mac-specific, it should be in the jazz-midi module: https://github.com/jazz-soft/jazz-midi
I have only tested it on Mac but I don't know if the problem is Mac-specific.
Just wonder why MIDI is used on the server side??
@jazz-soft hello, I use jzz on the server-side because I actually need to connect to a midi device on my server, but I was thinking...
@djipco What's the point of express here? Can you test without it?
I've setup a test on BunJS which will log the heap every 10 minutes, I'll post results in a hour or two.
@djipco What's the point of express here? Can you test without it?
Express is there because it was present in the scenario in which the potential memory leak was observed. Feel free to run tests without it.
Any updates on this?
Hmm, actually express isn't connected in any way, and what if it was a leak in that or just more traffic, maybe a minimal repro can be done?
As for me, well I tried the code, but I either couldn't reproduce or don't remember, but maybe I didn't try hard enough, or too different stack, I'm neither on Mac or used NodeJS