c++cmallocaudiotoolboxextaudiofile

ExtAudioFileOpenURL leak


I am opening an audio file to read it and I get an abandoned malloc block from this caller each time.

In a loop I set data like this (which is marked as the memory usage in instruments as 99.7%) data = (short*)malloc(kSegmentSize*sizeof(short));

and free it like this free(data); at the end of each iteration.

Im not really sure what is happening here and would appreciate any help.

EDIT: KSegmentSize varies in the thousands, from minimum 6000 - max 50000 (speculative)

Instruments trace:

enter image description here

enter image description here


Solution

  • Sorry to answer my own question, but after commenting out code back up the stack trace the actual issue was to do with the file not be disposed.

    Calling ExtAudioFileDispose(audioFile); solved this hidden bug. Instruments was not entirely clear and marked mallocs as the leak. To be fair the mallocs where from data that was within the file referenced by the ExtAudioOpenFile method, not disposing the file reference left a leak.