Occasionally I try to find alternatives for electron apps because I think that electron just uses too much RAM. This led me to a little Signal Desktop (an electron app) alternative called gurk, which uses significantly less RAM. On my machine Signal Desktop takes about 1GB RAM and gurk just 40MB. That’s an enormous reduction of memory usage, but not a completely fair comparison. Why? Because gurk requires a terminal to run in, which in my case is Alacritty.

So what about Alacritty?

Alacritty takes about 200MB RAM on my machine per process, which I think is a bit high in itself. Especially considering I use that terminal emulator for a ton of different things. Looking into the GitHub issues of Alacritty, I couldn’t find an easy way to reduce the memory usage. There were some mentions of video card drivers and fonts influencing the memory usage, but I’ll check that out later as I discovered something else.

Checking the Alacritty documentation, I spotted an argument called --daemon. It turns out that the terminal emulator can run multiple windows of itself in a single daemon process. This should cut down the relative memory usage of Alacritty depending on how many terminal windows I use at a given time.

Memory Usage Comparison

Before (3 separate Alacritty instances):

  • Process 1: ~200MB
  • Process 2: ~200MB
  • Process 3: ~200MB
  • Total: ~600MB

After (daemon mode with 3 windows):

  • Single daemon process: ~250MB
  • Total: ~250MB

This quickly makes running Alacritty in daemon mode much more efficient than running separate instances. I suppose crashes of Alacritty or other cases where the service can’t start could be a nuisance, but I have had no issues with Alacritty so far.

Setting up the daemon using systemd

Create ~/.config/systemd/user/alacritty.service with the following contents:

[Unit]
Description=Alacritty Daemon
Before=graphical-session.target
After=graphical-session-pre.target
PartOf=graphical-session.target
StartLimitIntervalSec=30
StartLimitBurst=3

[Service]
ExecStart=alacritty --daemon --socket %t/alacritty.sock
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=graphical-session-pre.target

Then run:

systemctl --user daemon-reload
systemctl --user enable alacritty.service --now

That’s all to set up the daemon. Then finally to start using it, create new Alacritty windows with:

alacritty msg create-window

And to start an application right away, like gurk:

alacritty msg create-window --command gurk

Troubleshooting

  • If the daemon fails to start, check journalctl --user -u alacritty.service
  • Ensure the socket directory exists: mkdir -p "$XDG_RUNTIME_DIR"