ios - viewDidUnload called after dealloc? -
when i'm debugging ipad app, found because of low memory, view controllers' viewdidunload
got called. seconds later, viewdidload
called. , again because of low memory, viewdidunload
, viewdidload
again. file system keep swapping files due low memory.
is supposed this, or have done wrong?
then wanna release view controller rid of this. viewdidunload
called before dealloc
, , crash due selector sent deallocated view controller.
thank help.
this normal behaviour. viewdidunload
called in low memory situation notify controller view has been released.
there's clear outline of steps in view controller programming guide ios.
specially, @ steps detailed in section understanding how views loaded , unloaded, covers unload cycle:
the app receives low-memory warning system.
each view controller calls didreceivememorywarning method. if override method, should use release memory or objects view controller object no longer needs. not use release view controller’s view. must call super @ point in implementation ensure default implementation runs. default implementation attempts release view.
if view cannot safely released (for example, visible onscreen), default implementation returns.
the view controller calls viewwillunload method inform subclasses views removed. subclass typically overrides viewwillunload method when needs save view properties before views destroyed.
and on.
in specific case, don't want release view controller in case. if there's further memory management want whilst there's low memory, should override default implementation of didreceivememorywarning. docs state, don't forget call [super didreceivememorywarning];
.
Comments
Post a Comment