PDA

View Full Version : Memory leak in SpeakHere




SameeraB
Nov 18, 2008, 09:18 PM
Hello Everyone,

I am stuck from past 3 days for fixing the memory leaks.

I have modified the SpeakHere application only for playing a (mp3) song. When i did launch this application using the Instrument I observed the memory leaks when the playing starts and playing stops.
I have added following in setUpAudioQueueBuffer() to support .mp3 playback.

bool isFormatVBR=(self.audioFormat.mBytesPerPacket == 0 || self.audioFormat.mFramesPerPacket == 0);
if(isFormatVBR)
{
packetDescriptions = (AudioStreamPacketDescription*)malloc(numPacketsToRead * sizeof(AudioStreamPacketDescription));
}
else
{
packetDescriptions=NULL;
}
I have freed packetDescriptions in dealloc() of AudioPlayer.m.
I have also freed audioLevel in AudioQueObject's dealloc.

But still I observed memory leaks. :( It is showing the memory leak in playbackCallback() as GeneralBolck-1024, generalblock-208 etc.

Any help regarding this problem is highly appreciable.

Thanks
Sameera



walty
Nov 19, 2008, 02:05 AM
Hm.. have u checked to confirm the dealloc is really called? As dealloc is to be called only when the reference count becomes zero.

SameeraB
Nov 19, 2008, 05:17 AM
Hi,

Thanks for the reply.

Yeah.. dealloc() is getting called.
I have also added following in dealloc()
AudioQueueRemovePropertyListener([self queueObject], kAudioQueueProperty_IsRunning, propertyListenerCallback, self);

int bufferIndex = 0;
for (bufferIndex = 0; bufferIndex < kNumberAudioDataBuffers; ++bufferIndex)
{

AudioQueueFreeBuffer ( [self queueObject], buffers[bufferIndex]);
}


But still i get the memory leaks..
What am I doing wrong?