So I've gotten to the nitty gritty part of my app development where I am going through checking for lingering memory leaks. I decided to give Xcode's Leaks a whirl. When I first ran it, it was telling me that I had no memory leaks. After a minute of rejoicing, I took a closer look, viewed the allocations and realized that I had several objects floating around in memory that I didnt want there. For instance, every time I created a UIAlertView (which was quite often in my app), I never release'd them when they were dismissed from the view. This led to having several UIAlertView objects floating around.

So, my question is: How does Leaks detect a memory leak? Why didn't tell me that there were any leaks when I had UIAlertView objects floating around? Am I just using Leaks wrong?

1 Answer
1

If you still have pointers to those UIAlertView instances, they aren't technically a leak yet. Only when your app can't get to them anymore it is considered a leak by the Leaks instruments. As you noticed, there are indeed ways to have stuff still around that you would expect to be gone. That's where the Allocations instrument comes in handy.