Why does MidiMessageSequence::getEventPointer() cause leaks?


#1

it seems that the following code causes leaks with the MidiEventHolder class:

for( int j = 0; j < mf.getNumTracks(); ++j ) {
    const MidiMessageSequence& mms = *(mf.getTrack(j));
    for( int k = 0; k < mms.getNumEvents(); ++k ) {
        if( !mms.getEventPointer(k)->message.isTempoMetaEvent() &&
            !mms.getEventPointer(k)->message.isEndOfTrackMetaEvent() ) { 
            //do something with mms.getEventPointer(k)->message
        }
    }
}

in my case, I was extracting all messages from a midi file excluding the tempo and endOfTrack messages.

this doesn’t leak and accomplishes the same thing:

        for( int j = 0; j < mf.getNumTracks(); ++j ) { //should be 1 track only
            for( int k = 0; k < 16; k++ ) {
                mf.getTrack(j)->extractMidiChannelMessages(k, extractedSequence, false);
            }
        }

I can’t figure out why the mms.getEventPointer()->message resulted in leaking MidiEventHolders when i shut down my application. What is the proper way to access the actual midi messages in a midi sequence?


#2

@matkatmusic I can’t seem to reproduce this - I’ve created a simple app that opens a MidiFile and then uses your code to print out the note numbers of the messages using mms.getEventPointer (k)->message.getNoteNumber() but I don’t get any leaks on shutdown. Are you sure you’re not leaking from somewhere else?

Ed