user1467188 user1467188 - 1 year ago 45
iOS Question

iOS questions about Instruments tool, memory issue in my app

I just started learning the instruments tool, and I'm pretty sure what I am seeing is not good. When I look at allocations, specifically the column "Live Bytes" and "Overall Bytes", I see the number continually increases as the app runs...

My app has two view controllers. A table view, and the second view controller displays detailed information about the row they selected in the table view, downloaded from the internet.

I kept clicking a row in the table view, followed by clicking the back button in the navigation bar... and LiveBytes continued to increase.

I'm guessing this means that my objects aren't being released from memory... but please correct me if I'm wrong.

MY QUESTION IS: How do I use the data in instruments/allocations to track down this memory issue? How do I find the objects not being released from memory?

I'm looking for tips on how to use these tools to clean up any memory problems my app has.

Thanks!

XCODE 4.2.1, deploying to iOS 5.0+

EDIT: I'm looking at the #living column and seeing objects like UIScrollView continuously increase... and never decrease. When I click the back button in a navigation bar, are objects automatically released from memory? When are objects released, or do I need to do it manually? Or could I be running into an issue due to using strong pointers, causing objects to not be released?

Answer Source

I think one of the best ways to solve memory issues is to use ARC.

Edit -> Refactor -> Upgrade to Objective-C ARC.

ARC will handle the majority of memory management in your app. Especially sice your app doesn't sound too complex, it might totally eliminate your problem. You still need to watch out for retain cycles and listen to memory warnings though. If you don't want to use ARC (which you should) at least run the static analyzer. Your problem might be something simple that the static analyzer can show you how to fix.

Edit:

You mentioned scroll views- this might be your problem: Memory leak every time UIScrollView is released

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download