View Full Version : Memory leak in SpeakHere

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);
packetDescriptions = (AudioStreamPacketDescription*)malloc(numPacketsToRead * sizeof(AudioStreamPacketDescription));
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.


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.

Nov 19, 2008, 05:17 AM

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?