Webkit Memory leak in iOS

Viewed 424

I have a memory leak on WebKit, and profiling through Xcode instruments gives a memory leak on the following.

WKHoverPlatter 1 0x281e7f7e0 96 Bytes WebKit -[WKContentView(WKInteraction) setUpInteraction]

Would anyone know how to fix this?

Here is my sample test code:

var webView: WKWebView!

override func loadView() {
    let webConfiguration = WKWebViewConfiguration()
    webView = WKWebView(frame: .zero, configuration: webConfiguration)
    webView.uiDelegate = self
    view = webView
}
override func viewDidLoad() {
    super.viewDidLoad()
    let myURL = URL(string:"https://www.apple.com")
    let myRequest = URLRequest(url: myURL!)
    webView.load(myRequest)
}
1 Answers

- (void)loadView;

This is where subclasses should create their custom view hierarchy if they aren't using a nib. Should never be called directly.

You can put your code in viewDidLoad.

override func viewDidLoad() {
    super.viewDidLoad()
    let webConfiguration = WKWebViewConfiguration()
    webView = WKWebView(frame: .zero, configuration: webConfiguration)
    webView.uiDelegate = self
    view = webView
    let myURL = URL(string:"https://www.apple.com")
    let myRequest = URLRequest(url: myURL!)
    webView.load(myRequest)
}
Related