问题
I have two table table controllers A and B. A has a list of items and when an item is clicked, it pushes to B. The problem is that when B was shown, the instrutment indicated a live memory increase, but it did not decreased when I clicked on back button. The dealloc method in B was executed but the memory seemed changed slightly. I checked that B was not retained anywhere else so what may the reasons that can cause this problem?
In B, there are many textfields, labels which are nonatomic and strong. I draw them in codes rather than using xibs. If I commented the codes for initializing them and adding them to the table header view, then the problem is gone.
I use Arc and simulator 6.1 by the way.
回答1:
It seems to me that some of the textfields/labels inside B might have some strong reference to B itself making it impossible for arc to release them cause B has a strong pointer to and element inside it and this element has a strong pointer to B.
As far as I know thats not the default behaviour of textfields/labels, but maybe you've subclassed them...
Hard to try anything other than guessing with that little amount of information you gave
回答2:
Do you need the views to be accessible in the view controller context? Can you not assign a tag to them and retrieve them from the tableview header when you need to change them?
来源:https://stackoverflow.com/questions/15862231/navigation-arc-memory-not-released