Ram Guard
Ram Guard is a lightweight, utility tool for managing memory usage on your system. It helps prevent running out of memory by listening for user-defined intervals and thresholds; if memory usage exceeds the threshold, Ram Guard finds the most resource-hungry process and stops it in its tracks.
🛠️ Installation
-
Clone the repository:
git clone https://github.com/owbird/ram-guard.git
cd ram-guard
-
Install dependencies:
go mod tidy
-
Run Ram Guard:
go run .
⚙️ Usage
Configure interval
and threshold
as command-line arguments or use defaults of 70% and 5s:
ram-guard --interval <time_in_seconds> --threshold <RAM_limit_in_%>
Example
To set Ram Guard to check every 10 seconds and act if RAM usage exceeds 80%:
ram-guard --interval 10 --threshold 80
🔍 How It Works
- Interval Listener: Ram Guard listens for the specified interval.
- Threshold Check: Compares current RAM usage with the defined threshold.
- Process Termination: If usage exceeds the threshold, Ram Guard identifies the largest process by memory usage and terminates it while notifying you.
🛡️ Safety Notice
Use Ram Guard cautiously, as it automagically terminates high-memory processes. Avoid setting the threshold too low, which could inadvertently stop essential services.
🤝 Contributing
Contributions are welcome! If you’d like to contribute, please open an issue or submit a pull request with suggested changes.