macOS Orphan Process Cleanup
A dependency-free Bash utility that reclaims memory from leftover headless Chrome instances and stale Godot MCP server processes on macOS.
Automation tools can leave headless browsers and MCP server processes running long after their original sessions end. I built this command-line utility to identify those leftovers and reclaim their memory using Bash and tools included with macOS, without additional dependencies or elevated privileges.
What it does
- Targets headless Chrome instances and configured Godot MCP server processes.
- Applies a configurable age cutoff to MCP servers so recently started servers are kept.
- Offers a dry-run mode to preview matching processes before cleanup.
- Logs process counts and memory reclaimed, with before-and-after RSS measurements.
Technical notes
The script uses command-line process matching and elapsed-time checks to select cleanup candidates. Its patterns can be adjusted for other tooling. Headless Chrome matches are cleaned up regardless of age; the age cutoff applies to MCP servers. It is a practical cleanup utility, not a fix for the tools that leak processes. Reviewing a dry run first is recommended.