From 5a316c0c41eb900f408567f61ba3e91cac57d635 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 23 Apr 2014 08:50:26 +0800 Subject: [PATCH] Free memory when native window is closed. --- atom/browser/api/atom_api_window.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 989f153..cb65ce9 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -98,6 +98,10 @@ void Window::WillCloseWindow(bool* prevent_default) { void Window::OnWindowClosed() { Emit("closed"); + + // Free memory when native window is closed, the delete is delayed so other + // observers would not get a invalid pointer of NativeWindow. + base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release()); } void Window::OnWindowBlur() { -- 2.7.4