Oops, there's a memory leak there. The Lua destructor isn't cleaning up the track, so that's 2KB of note list memory lost each time. But noteTrack:clearNotes()
should do what you want. One tiny implementation detail I notice there: Nope, I'm wrong, the buffer isn't allocated until you add the first note.clearNotes()
frees the note storage every time, even though the initializer pre-allocates 2KB of storage. That means in your case it's freeing then reallocating the same memory every time. I should instead have clearNotes() shrink it to 2KB if it's bigger, otherwise do nothing but change the number of notes to 0.
1 Like