Memory leak with currentViewController in iOS keyboard expansion
I am writing a keyboard extension for iOS in Objective-C. At some point in viewController1
I present another view controller
CustomViewController *viewController2 = [[CustomViewController alloc] init];
[self presentViewController:viewController2 animated:NO completion:nil];
The problem occurs in the following scenario: Another application is open with my extension as the active keyboard. viewController2
and the extension exits (by pressing the home button). When the app restarts, it is viewController2
no longer displayed, but it viewController1
is. From memory consumption I can see what viewController2
is still in memory. Repeating the steps at this point quickly fails due to too much memory consumption.
This does not happen when normal user actions are performed in viewController2
, after which
[self dismissViewControllerAnimated:NO completion:nil];
... Also, I made it 100% sure that there are no strong references that can leak memory. I also tried to get a message when ( viewWillDisappear
etc.) is called dismissViewControllerAnimated:NO
, but it seems that pressing the home button instantly kills the extension.
viewController1
is UIInputViewController
and acts as a delegate for CLLocationManager
, but UICollectionView
, viewController2
is UIViewController
and does not act as a delegate at all. I do not support any links from viewController1
to viewController2
, and weak from viewController2
to viewController1
.
@property (weak, nonatomic) viewController1 *parent;
Does anyone have an idea what's going on? What can I do to prevent this?
Many thanks for your help!
source to share
No one has answered this question yet
Check out similar questions: