From f519f1bb5d8e35902aa1a3fbefdcb42900924e32 Mon Sep 17 00:00:00 2001 From: Jessie Hildebrandt Date: Sat, 4 Aug 2018 19:48:28 -0400 Subject: [PATCH] Improve garbage collection behavior --- init.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/init.el b/init.el index aa34a78..7167d9f 100644 --- a/init.el +++ b/init.el @@ -206,11 +206,11 @@ ;; Increase the garbage collection threshold to 100MB for a faster startup time. (setq-default gc-cons-threshold 100000000) -;; Restore it to 20MB after 5 seconds. -(run-with-idle-timer - 5 nil - (lambda () - (setq gc-cons-threshold 20000000))) +;; Restore it to 8MB after initialization is finished. +(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold 8000000))) + +;; Collect all garbage whenever Emacs loses focus. +(add-hook 'focus-out-hook #'garbage-collect) ;;========================================