I have built an iOS app that is almost done, however, I have recently experienced that it crashes after while due to \"Memory pressure\". So I started profiling the memory alloc
Instruments is saying that your UIViews are leaking (or not deallocated to be precise).
Each push will create a new destinationController
and the destinationController's
view will be backed by a CALayer and CALayer kills memory.
To prove that, you can just implement dealloc
for your destinationController
and set a breakpoint there to see if it's called.
If the dealloc is called than you can do this for other objects to find out which one. (Like destinationController.view
)
Why leaking?
1, You may have retain cycles that capturing destinationController
. It's a pain to debug, you may have to check through all your code related.
2, Every destinationController
may be retained by some long living object. (Repeated NSTimer that are not invalidated, Singleton, RootViewController, CADisplayLink ...)
3, False cache. You cache something and try to reuse it. However, the cache logic has bugs and those objects never get reused and new objects are constantly inserted in.