Emacs Garbage Collection

Bailey Ling over at bling on software has a great post on tuning Emacs garbage collection. Most of us never think about Emacs garbage collection but Ling shows that it can have an effect on performance.

The Emacs garbage collection strategy is pretty simple: once it’s allocated a certain amount of memory, it stops and does garbage collection. The default threshold is pretty small: 800 KB. It seems to make sense, given today’s systems, to increase this. The problem, Ling says, is that if you increase it too much there’s a lot of memory to recover and it can stop things for 20 seconds or more. That’s clearly not acceptable.

On the other hand, if it’s too small Emacs spends a large proportion of its time garbage collecting, also not optimal. It turns out that the Emacs manual has a solution and Ling has ferreted it out for us. Head over to Ling’s site for the details. If you’re seeing Emacs delay processing often or for long times, garbage collection may be the problem and you should check out Ling’s post.

The garbage collection threshold is a simple variable that is easily changed in your init.el so it’s easy to experiment with different values or to try Ling’s solution.

This entry was posted in General and tagged . Bookmark the permalink.