Periodic Restarts: A Brute-Force Workaround For Reducing Guard Memory

By 1AEO Team • January 2026

Experiment: 40 relays over 10 days (Dec 2025–Jan 2026) testing 24h, 48h, 72h intervals vs glibc (control)

If you can't change your memory allocator, scheduled restarts offer a fallback strategy. We tested three restart intervals across 30 relays to measure effectiveness—and the tradeoffs.

The Results

Restart IntervalAvg Memoryvs ControlTradeoff
Every 24 hours4.88 GB-13%High churn
Every 48 hours4.56 GB-19%Moderate
Every 72 hours5.29 GB-6%Low impact
Control (no restarts)5.64 GBBaseline
Restart Interval Memory Comparison

The 48-hour interval performed best, but even then memory averaged 4.56 GB—still 3-4x higher than what modern allocators achieve (1.1–1.6 GB).

Why Restarts Help (A Little)

Restarting a Tor relay forces the process to release all memory back to the OS and start fresh. For the first 24-48 hours after restart, memory usage is reasonable. Then fragmentation kicks in and RSS climbs back toward 5+ GB.

The sawtooth pattern is predictable:

The Tradeoffs

Scheduled restarts come with costs:

  1. Circuit disruption: Active circuits are terminated, forcing clients to rebuild
  2. Warmup period: Relay must re-establish connections and rebuild routing tables
  3. Operational overhead: Requires cron/systemd timers and monitoring
  4. Diminishing returns: 24h restarts only save ~13% vs no restarts

Implementation

If you must use restarts, here's a systemd timer approach:

# Create timer: /etc/systemd/system/[email protected]
[Unit]
Description=Restart Tor relay %i every 48 hours

[Timer]
OnBootSec=48h
OnUnitActiveSec=48h
RandomizedDelaySec=1h

[Install]
WantedBy=timers.target
# Enable for a relay
sudo systemctl enable --now tor-restart@relay_name.timer

The RandomizedDelaySec staggers restarts across relays to avoid simultaneous disruption.

When to Use Restarts

Better Alternative

Restarts are a band-aid. Switching to mimalloc or jemalloc eliminates the need entirely—memory stays flat at 1-2 GB indefinitely without any service interruption.

ApproachMemoryService Impact
mimalloc 2.11.16 GBNone
jemalloc 5.31.63 GBNone
48h restarts4.56 GBEvery 48 hours
No action5.64 GBNone (but wasted RAM)

📊 Raw data: View experiment data and relay configs on GitHub

Join the Mission