Skip to content

v0.9.19

Choose a tag to compare

@ProphetSe7en ProphetSe7en released this 24 Apr 13:59
· 6 commits to main since this release

Memory-leak fix. Constat kept a ring-buffer + aggregated-history + averages entry for every container name it ever saw, forever — including transient one-shots (docker run without --name → auto-generated names like admiring_hofstadter). On systems that ran many one-shots over time, 60%+ of in-memory stats was phantoms.

Fixed

  • Phantom-container accumulation in stats history. Three cleanup mechanisms added:
    1. Docker destroy event handler — when a container is fully removed (explicit docker rm or --rm auto-cleanup), the event stream now calls StatsCollector.RemoveContainer(name) to purge the entry from history, aggregated, averages, latest, meta, status, prevNet, streams, and reverse-map idToName. Previously destroy was silently ignored.
    2. Startup prune — 30 s after boot, StatsCollector.PruneStale runs one pass against docker ps -a and removes any tracked name Docker no longer knows about. Flushes accumulated backlog from prior versions.
    3. Hourly safety-net scan — same PruneStale runs every hour to catch destroys the event stream might have missed (reconnect gaps, daemon restarts).
  • History is keyed by container name, not ID — stats for real containers survive Unraid Force Update / image upgrades / ID changes intact. The cleanup only removes names Docker itself has forgotten about.

Notes

  • No config knobs. Keeping stats for removed containers was a bug, not a feature.
  • Logs StatsCleanup: pruned N stale container(s) from stats history on every non-zero prune.
  • Expect a one-time RAM drop on first boot after upgrade if you had accumulated phantoms. Steady state thereafter.

Full changelog: https://github.com/ProphetSe7en/constat/blob/main/CHANGELOG.md