AudioBufferList增加内存使用量

时间:2013-12-23 06:04:58

标签: ios c memory-management malloc core-audio

我在循环中有以下代码(每1/4秒调用一次)。 (我已经删除了其余代码以将问题缩小到以下内容。)

dispatch_async(self.audioQueue, ^{

        AudioBufferList *aacBufferList;

        aacBufferList = malloc(sizeof(AudioBufferList));
        aacBufferList->mNumberBuffers = 1;
        aacBufferList->mBuffers[0].mNumberChannels = aacStreamFormat.mChannelsPerFrame;
        aacBufferList->mBuffers[0].mDataByteSize   = maxOutputPacketSize;
        aacBufferList->mBuffers[0].mData           = (void *)(calloc(maxOutputPacketSize, 1));

        // Other code was here. As stated above, I have removed it to isolate the problem to the allocating and freeing of memory for the AudioBufferList

        freeABL(aacBufferList);
}

freeABL功能:

void freeABL(AudioBufferList *abl)
{

    for (int i = 0; i < abl->mNumberBuffers; i++)
    {
        free(abl->mBuffers[i].mData);
        abl->mBuffers[i].mData = NULL;
    }
    free(abl);
    abl = NULL;
}

我遇到的问题是每次循环增加我的应用程序的内存消耗,直到收到内存警告。

Instruments showing __NSMallocBlock__ Increasing in size

0 个答案:

没有答案