zoliky · 2022-08-13 11:46
Hello, if I add this to my Emacs config does it cause anything wrong to the functioning of Emacs? I think forcing a GC beside the normal GC shouldn't cause any issue, especially because when I force it is when the Emacs frame is not in focus.
(add-hook 'focus-out-hook 'garbage-collect)
I also have Emacs set to save the file when the frame is out of focus, but I think the two shouldn't collide.
S_Nathan · 2022-08-13 12:13
I guess there is no real harm in doing so, but ... have you encountered performance problems with Emacs that you can trace to the garbage collector?
zoliky · 2022-08-13 12:15
No performance issues. However, my Emacs starts up faster when I avoid garbage collection during startup. I configured my `early-init.el` to avoid GC at startup, then later on I dial the large value back. When I dial the value back I use a larger value than default 800KB, this one: `(setq gc-cons-threshold (* 20 1024 1024)` it is what Steve Purcell uses in his emacs.d config.
S_Nathan · 2022-08-13 12:27
I guess you can do what you describe in your post, but I really don’t see the point of doing it. I guess I sound like an old man but: I start Emacs once when I log in and restart it after upgrading packages.
I just checked and spacemacs sets \`gc-cons-threshold' and \`gc-cons-percentage' to 100000000 and 0.1 respectively and it works fine for me.
arthurno1 · 2022-08-13 13:00
It all depends on how you use Emacs. Potentially, in some hypothetical heavy usage scenario, and more than one Emacs frame (top level window), you could trigger garbage collection when you switch between Emacs frames and maybe experience Emacs blocking until gc has done its job. But if you are usually using Emacs with just one frame per process, it does not matter. I don't think it will give you any benefit either :-), and is unnecessary, but it probably won't do harm.
deaddyfreddy · 2022-08-13 13:10
I just use https://gitlab.com/koral/gcmh
jangid · 2022-08-14 04:23
Restarting after package upgrades? Is this necessary?
S_Nathan · 2022-08-14 05:31
Not always. But spacemacs works a little differently, so when using spacemacs it is necessary.
jangid · 2022-08-14 08:05
Ok. Never used that.
github-alphapapa · 2022-08-15 20:27
If you want an upgraded package to take effect, you need to either unload the package and reload it (e.g. using [this](https://github.com/alphapapa/unpackaged.el#reload-a-packages-features)), or restart Emacs.