开发者

How do Leaks happen?

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 rele开发者_开发知识库ase'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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜