Memory leak in SpeakHere

Discussion in 'iOS Programming' started by SameeraB, Nov 18, 2008.

  1. SameeraB macrumors newbie

    Nov 18, 2008
    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.

  2. walty macrumors member

    Jul 15, 2008
    Hm.. have u checked to confirm the dealloc is really called? As dealloc is to be called only when the reference count becomes zero.
  3. SameeraB thread starter macrumors newbie

    Nov 18, 2008

    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?

Share This Page