diff --git a/core/core.el b/core/core.el index ef6f4fd7d..6ba9ffba6 100644 --- a/core/core.el +++ b/core/core.el @@ -245,16 +245,6 @@ original value of `symbol-file'." (funcall orig-fn symbol type))) (advice-add #'symbol-file :around #'doom*symbol-file) -;; To speed up minibuffer commands (like helm and ivy), defer garbage collection -;; when the minibuffer is active. It may mean a pause when finished, but that's -;; acceptable instead of pauses during. -(defun doom|defer-garbage-collection () - (setq gc-cons-threshold doom-gc-cons-upper-limit)) -(defun doom|restore-garbage-collection () - (setq gc-cons-threshold doom-gc-cons-threshold)) -(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection) -(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection) - ;; File+dir local variables are initialized after the major mode and its hooks ;; have run. If you want hook functions to be aware of these customizations, add ;; them to MODE-local-vars-hook instead. @@ -273,6 +263,23 @@ original value of `symbol-file'." (add-hook 'after-change-major-mode-hook #'doom|run-local-var-hooks-if-necessary) +;; +;;; Garbage collector optimizations + +;; To speed up minibuffer commands (like helm and ivy), defer garbage collection +;; when the minibuffer is active. It may mean a pause when finished, but that's +;; acceptable instead of pauses during. +(defun doom|defer-garbage-collection () + (setq gc-cons-threshold doom-gc-cons-upper-limit)) +(defun doom|restore-garbage-collection () + (setq gc-cons-threshold doom-gc-cons-threshold)) +(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection) +(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection) + +;; GC all sneaky breeky like +(add-hook 'focus-out-hook 'garbage-collect) + + ;; ;;; Incremental lazy-loading diff --git a/init.el b/init.el index f50f928a3..f67b43ae6 100644 --- a/init.el +++ b/init.el @@ -31,7 +31,7 @@ "The default value to use for `gc-cons-threshold'. If you experience freezing, decrease this. If you experience stuttering, increase this.") -(defvar doom-gc-cons-upper-limit 268435456 ; 256mb +(defvar doom-gc-cons-upper-limit 536870912 ; 512mb "The temporary value for `gc-cons-threshold' to defer it.")