WKWebView memory issue causes crash

I have a simple app with a WKWebView. When running on iOS 9.3, the memory usage stays around 5 Mb with is expected since WKWebView runs in a separate process. But memory usage for “other processes” goes high after a couple of navigations, especially on heavy pages. When the memory usage reaches its threshold, the app gets two memory warnings and then gets terminated. The debugger gives no output. I find this behavior unexpected since one of the features with WKWebView is that the app won’t terminate when WKWebView runs out of memory. It should instead kill the WKWebView process and trigger webViewWebContentProcessDidTerminate. But webViewWebContentProcessDidTerminate is never called.


This is my code:

import UIKit
import WebKit

class MyAwsomeWebViewController: UIViewController, WKNavigationDelegate {
    var page:WKWebView! = WKWebView()

    @IBOutlet weak var WKBaseView: UIView!
    override func viewDidLoad() {
        page.navigationDelegate = self
        if let url = URL(string: "https://hitta.se") {
            let request = URLRequest(url: url)

    override func loadView() {
        self.view = page
    override func didReceiveMemoryWarning() {
        print("**** MEMORY WARNING! ****")
    func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
        print("*** Terminate WebView Process ***")


Why does my app get terminated and how can I prevent this?

Powered by WPeMatico

You may also like...

Comments are closed.