prethushpj
prethushpj

Reputation: 1

ARC not seems to be working when upgraded to Xcode 5 from Xcode 4.2

I was working with a project in Xcode 4.2, which is not using any storyboards but normal xib's. ARC was working super fine and was happy with that, No problems.

Now the Odd problem araised when I upgraded from Xcode 4.2 to Xcode 5 (Still not using storyboards). I pop a screen using 'popViewControllerAnimated' function, and obviously, the Screen is popped.

But when I analyzed on the memory allocation, I found that the screen memory is not released even after the screen is popped.

Moreover, when I open that screen again, memory is allocated and not released even when I close it. Seems more like a retain cycle, but I'm damn sure that I've never used 'retain'.

Now I've upgraded to Xcode 5.1.1 and this Odd issue, still persists.

To convert my project to 'Storyboard' design is a complete burden for me thats why I'm preserving ordinary xib's.

I'm now tired of Google'ing and searching all the forums including Stackoverflow.com.

Guys, Please help me figure out the issue.

Its a life Saver for me.

Upvotes: 0

Views: 99

Answers (2)

gabuh
gabuh

Reputation: 1166

Check if you are setting in one view controller as the delegate of the popped view controller. Because when that popped view controller is dismissed, you must set the delegate to nil. Is common to forget this.

Upvotes: 0

Duncan C
Duncan C

Reputation: 131398

ARC is not magic. ARC keeps track of strong references to objects. When the number of strong (owning) references to an object drops to zero, the object gets deallocated.

If one of your view controllers is not being released, it means there is a strong reference to it somewhere. One possibility is a "retain cycle", where 2 objects each have strong references to each other. This happens when you do things like have an object that owns another helper object, and the helper object has a (strong) pointer back to the owning object. The usual solution is to make owners keep strong references to their objects, and owned-to-owning pointers weak (like delegates).

There is no way for SO readers to find your problem for you.

Have you tried running the analyze tool on your code? It may point to the problem for you. You should also run the program through the Leaks instrument as Phillip suggested. Both of those tools are very helpful, although neither is 100% foolproof.

Failing that, you might need to find a senior-level iOS developer with whom you can sit down and do a code review. Often, in the process of explaining the logic and implementation of your program to somebody else, you find the problem yourself.

Upvotes: 2

Related Questions