title: Huge Memory Leaks NSData
body: <p>Im working on a music streaming application. Im currently receiving signs of huge memory leaks. Instruments says its related to the code below. There are some blocks of memory being allocated during the while loop. I have ARC turned on. I have exhausted all options and need some more ideas</p>
  
  <pre><code>NSData * ringBufferReadData = [NSData dataWithBytes:readPointer length:allBytesAvailable];
  // NSLog(@"READER: THESE ARE THE BYTES WE ARE ABOUT TO READ FROM RING BUFFER %lu ",allBytesAvailable);
  
  [ringBuffer didReadLength:allBytesAvailable];
  
  UInt32 ringBufferReadDataOffset = 0;
  
  while (ringBufferReadDataOffset &lt; allBytesAvailable) {
  
      int packetBytesFilled = [[ringBufferReadData subdataWithRange:NSMakeRange(12 + ringBufferReadDataOffset, 4)] pm_int32AtOffset:0];
  
      int packetDescriptionsBytesFilled = [[ringBufferReadData subdataWithRange:NSMakeRange(16 + ringBufferReadDataOffset, 4)] pm_int32AtOffset:0];
  
      int offset = AUDIO_BUFFER_PACKET_HEADER_SIZE + ringBufferReadDataOffset;
      NSData* audioBufferData = [NSData dataWithBytes:(char *)([ringBufferReadData bytes] + offset) length:packetBytesFilled];
  
      offset += packetBytesFilled ;
      NSData *packetDescriptionsData = [NSData dataWithBytes:(char *)([ringBufferReadData bytes] + offset) length:packetDescriptionsBytesFilled];
  
      UInt32 inNumberPackets = packetDescriptionsBytesFilled/AUDIO_STREAM_PACK_DESC_SIZE;
      AudioStreamPacketDescription *inPacketDescriptions;
  
      inPacketDescriptions = [self populatePacketDescriptionArray:packetDescriptionsData
                                          packetDescriptionNumber:inNumberPackets];
  
      if (inPacketDescriptions[0].mDataByteSize &gt; 65536)
      {
          NSLog(@"packet description size is abnormally large.. soething is wrong");
      }
  
      [self handleAudioPackets:[audioBufferData bytes]
                   numberBytes:packetBytesFilled
                 numberPackets:inNumberPackets
            packetDescriptions:inPacketDescriptions];
  
      ringBufferReadDataOffset += AUDIO_BUFFER_PACKET_HEADER_SIZE + packetBytesFilled + packetDescriptionsBytesFilled;
  
      free(inPacketDescriptions);
  }
  </code></pre>