From: Cheng Zhao Date: Fri, 10 Jan 2014 03:04:54 +0000 (+0800) Subject: Leak the node environment when unloading. X-Git-Tag: v0.8.4~10 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e536d0e7a80f3ae120e5be67868cdd1a80bf9cf1;p=electron.git Leak the node environment when unloading. --- diff --git a/renderer/atom_renderer_client.cc b/renderer/atom_renderer_client.cc index c295eb6f..770a449d 100644 --- a/renderer/atom_renderer_client.cc +++ b/renderer/atom_renderer_client.cc @@ -77,11 +77,19 @@ void AtomRendererClient::WillReleaseScriptContext( } // Clear the environment. - env->Dispose(); web_page_envs_.erase( std::remove(web_page_envs_.begin(), web_page_envs_.end(), env), web_page_envs_.end()); + // Notice that we are not disposing the environment object here, because there + // may still be pending uv operations in the uv loop, and when they got done + // they would be needing the original environment. + // So we are leaking the environment object here, just like Chrome leaking the + // memory :) . Since it's only leaked when refreshing or unloading, so as long + // as we make sure renderer process is restared then the memory would not be + // leaked. + // env->Dispose(); + // Wrap the uv loop with another environment. if (env == node_bindings_->get_uv_env()) { node::Environment* env = web_page_envs_.size() > 0 ? web_page_envs_[0] :