Skip to content

Feature/prevent duplicate timers

(Thanks for creating gcmh. I'm using it on both Windows and Linux and it's especially helpful on Windows.)

I found that when combined with desktop-save-mode, upon session reloading in a new Emacs instance, then gcmh-mode would be enabled multiple times even when it was already active. This causes multiple duplicate idle timers to be created (one for each time the mode is enabled).

The same effect can be provoked by manually running (gcmh-mode t) multiple times.

The effect of this is garbage collection being executed multiple times each time the idle time expired.

I noticed this because GC was slower than expected, and turning on gcmh-verbose revealed all those duplicate GC events each time Emacs had been idle.

This change simply removes any extant timer before enabling the mode so we're guaranteed to only have one or zero idle timers defined.

Merge request reports