alexbw/novocaine — pull request #20 by mike-es (2012-07-07 04:09:07+00:00)
Title: Improved memory usage

First of all, thanks for the great library. I am using novocaine for an iOS app I'm working on and I spent a good amount of time running my app through Instruments. In doing so, I found a few memory leaks that were causing my app to consume a lot of memory.

There were a few minor leaks in *Novocaine.m*. I added a destructor to *RingBuffer.m* to free the `mData` array, and removed the TODO comment :)

The one causing the major memory usage was a bit hard to find. My use case requires creating many instances of *AudioFileReader*'s (each time a user selected a new song) and each time I call `[fileReader play]` which creates the GCD queue. When I go to create another *AudioFileReader*, I call release on the first one but the dealloc method is never called. The reason is because the queue still has a reference to the instance. I added a `stop` method that calls `dispatch_release()`. Now I call `[fileReader stop]` before creating a new one and the memory is deallocated.

This library saved me a ton of time. Great work!