I am currently working with the DryWetMidi
package to control the KORG nanoKONTROL2 MIDI board with C#
/.Net
and I noticed that the memory of my application will increase when I fire a lot of MIDI messages (in other words: when I move the faders a lot).
For inspection purposes, I wrote this simple code, which basically does nothing but initializing the DryWetMidi
package to start listening to MIDI messages send by my device. Then I have 100 seconds to try out various faders/buttons/knobs (and send a lot of MIDI messages)
static async Task Main(string[] args)
{
InputDevice nano = InputDevice.GetByName("nanoKONTROL2");
nano.StartEventsListening();
Console.WriteLine("start");
for (int i = 1; i < 101; i++)
{
await Task.Delay(1000);
Console.WriteLine(i + " seconds passed");
}
Console.WriteLine("end");
nano.StopEventsListening();
nano.Dispose();
}
The memory starts increasing by approx. 15MB when I move the faders a lot. The memory only increases when I move anything (when the board sends MIDI messages)! Since the memory does not increase further after these 15MB, I assume that there are some logging processes going on in the background? Or is it some kind of memory leak?
Now my question:
Is there any way to prevent this memory increase?
I'm the author of the DryWetMIDI library. I've passed MIDI events receiving through .NET memory profiler and here my conclusions:
MidiEvent
class created by DryWetMIDI when new data arrived from a device.I don't see any problems. There are no memory leaks and of course there is no any logging within the library. What you see is how .NET memory management works.