diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 890b57784e16..b0f08cd32fa0 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -28,7 +28,8 @@ AtomBrowserMainParts* AtomBrowserMainParts::self_ = NULL; AtomBrowserMainParts::AtomBrowserMainParts() : browser_(new Browser), node_bindings_(NodeBindings::Create(true)), - atom_bindings_(new AtomBindings) { + atom_bindings_(new AtomBindings), + gc_timer_(true, true) { DCHECK(!self_) << "Cannot have two AtomBrowserMainParts"; self_ = this; } @@ -75,6 +76,13 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() { node_bindings_->PrepareMessageLoop(); node_bindings_->RunMessageLoop(); + // Start idle gc. + gc_timer_.Start( + FROM_HERE, base::TimeDelta::FromMinutes(1), + base::Bind(base::IgnoreResult(&v8::Isolate::IdleNotification), + base::Unretained(js_env_->isolate()), + 1000)); + brightray::BrowserMainParts::PreMainMessageLoopRun(); #if defined(USE_X11) diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index a221ea62cd7b..4ad0185c4350 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -5,6 +5,7 @@ #ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_ #define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_ +#include "base/timer/timer.h" #include "brightray/browser/browser_main_parts.h" namespace atom { @@ -43,6 +44,8 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { scoped_ptr atom_bindings_; scoped_ptr node_debugger_; + base::Timer gc_timer_; + static AtomBrowserMainParts* self_; DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);