Skip to content

Commit

Permalink
fix: prevent memory leak on macOS, closes #536 (#587)
Browse files Browse the repository at this point in the history
* fix: prevent memory leak on macOS, closes #536

* Add change file

Co-authored-by: Yu-Wei Wu <wusyong9104@gmail.com>
  • Loading branch information
keiya01 and Yu-Wei Wu committed May 20, 2022
1 parent 494a110 commit 16d1924
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changes/memleak.md
@@ -0,0 +1,5 @@
---
"wry": patch
---

Prevent memory leak on macOS.
11 changes: 2 additions & 9 deletions src/webview/wkwebview/mod.rs
Expand Up @@ -645,15 +645,8 @@ impl Drop for InnerWebView {
}
}

// WKWebview has a single WKProcessPool to manage web contents.
// The WKProcessPool is not reset even if WKWebview is deallocated.
// So we need to override the process by navigating to `about:blank`.
self.navigate("about:blank");

let _: Id<_> = Id::from_ptr(self.webview);
#[cfg(target_os = "macos")]
let _: Id<_> = Id::from_ptr(self.ns_window);
let _: Id<_> = Id::from_ptr(self.manager);
let _: Id<_> = Id::from_retained_ptr(self.webview);
let _: Id<_> = Id::from_retained_ptr(self.manager);
}
}
}
Expand Down

0 comments on commit 16d1924

Please sign in to comment.