]> khamidou — GitHub mirrors - electron.git/commitdiff
Leak the node environment when unloading.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 10 Jan 2014 03:04:54 +0000 (11:04 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 10 Jan 2014 03:04:54 +0000 (11:04 +0800)
renderer/atom_renderer_client.cc

index c295eb6fc591a1522068f1a80b2e410798174d18..770a449d3eba100a03e4abf633c6dc73a73366b1 100644 (file)
@@ -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] :