Skip to content

isyundong/Memory-Pressure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Memory Pressure Monitor

Memory Pressure Icon

A lightweight macOS application that monitors system memory usage and displays real-time memory pressure information in the menu bar.

Features

πŸ” Real-time Monitoring

  • Continuous monitoring of system memory usage
  • Real-time memory pressure status detection
  • Automatic updates with configurable intervals
  • Low system resource consumption

πŸ“Š Multiple Display Formats

  • Percentage: Shows memory usage as a percentage
  • Absolute Values: Displays used/total memory in GB
  • Combined: Shows both percentage and absolute values
  • Color-coded status indicators for quick assessment

βš™οΈ Flexible Configuration

  • Customizable update intervals (1s, 2s, 5s, 10s)
  • Adjustable memory pressure thresholds
  • Menu bar icon visibility control
  • Launch at login option
  • Notification preferences

πŸ”” Smart Notifications

  • Automatic alerts when memory usage exceeds thresholds
  • Customizable critical memory threshold (default: 90%)
  • Non-intrusive notification system
  • Option to disable notifications

πŸ’Ύ Configuration Management

  • Persistent settings using macOS UserDefaults
  • JSON configuration export/import
  • Easy backup and restore of preferences
  • Cross-device configuration sharing

🌍 Multi-language Support

  • English
  • Chinese (Simplified)
  • Russian
  • French
  • German
  • Real-time language switching

System Requirements

  • macOS: 13.0 (Ventura) or later
  • Swift: 5.9 or later
  • Xcode: 15.0 or later (for development)

Installation

Using Swift Package Manager

  1. Clone the repository:
git clone https://github.com/yourusername/memory-pressure.git
cd memory-pressure
  1. Build the project:
swift build
  1. Run the application:
swift run

Creating Executable

# Build release version
swift build -c release

# Copy executable to Applications
cp .build/release/MemoryPressure /Applications/

# Or create symbolic link
ln -s $(pwd)/.build/release/MemoryPressure /usr/local/bin/memory-pressure

Using Build Script

# Make build script executable
chmod +x build_app.sh

# Build application bundle
./build_app.sh

# The app will be created in the dist/ directory
open "dist/Memory Pressure.app"

Usage

Getting Started

  1. Launch the application - it will appear in the macOS menu bar
  2. Click the menu bar icon to view detailed memory information
  3. Select "Settings" to open the configuration window
  4. Customize the display format, update interval, and other preferences

Menu Bar Display

The menu bar icon shows memory status with color-coded indicators:

  • 🟒 Normal (Green): Memory usage is normal
  • 🟑 Warning (Yellow): Memory usage is elevated, consider closing unnecessary apps
  • πŸ”΄ Critical (Red): Memory usage is high, may affect system performance
  • πŸ†˜ Danger (Purple): Memory usage is extremely high, system may become unresponsive

Menu Options

  • Memory Information: Displays detailed memory usage statistics
  • Refresh: Manually refresh memory information
  • Settings: Open configuration window
  • Quit: Exit the application

Settings Configuration

Update Frequency

  • Fast (1s): For precise monitoring scenarios
  • Normal (2s): Default setting, balances performance and accuracy
  • Slow (5s): Conserves system resources
  • Very Slow (10s): Minimal resource consumption

Display Format Options

  • Percentage: Shows memory usage as a percentage (e.g., "85%")
  • Absolute: Shows used/total memory in GB (e.g., "12.8/16.0 GB")
  • Percentage + Absolute: Shows both formats (e.g., "85% (12.8/16.0 GB)")

Additional Options

  • Show Menu Bar Icon: Control menu bar icon visibility
  • Launch at Login: Set application to start automatically at login
  • Show Memory Pressure Notifications: Enable/disable memory warning notifications
  • Critical Memory Threshold: Customize the threshold for critical memory alerts (default: 90%)

Configuration File

The application uses macOS UserDefaults for configuration storage and supports JSON configuration export/import.

Configuration Format

{
  "updateInterval": 2.0,
  "displayFormat": "percentage",
  "showMenuBarIcon": true,
  "launchAtLogin": false,
  "showNotifications": true,
  "criticalMemoryThreshold": 0.90,
  "language": "en"
}

Configuration Options

Option Type Default Description
updateInterval Number 2.0 Update frequency in seconds
displayFormat String "percentage" Display format: "percentage", "absolute", or "both"
showMenuBarIcon Boolean true Show/hide menu bar icon
launchAtLogin Boolean false Launch application at system startup
showNotifications Boolean true Enable memory pressure notifications
criticalMemoryThreshold Number 0.90 Critical memory threshold (0.0-1.0)
language String "en" Interface language code

Troubleshooting

Application Won't Start

  1. Verify macOS version meets requirements (13.0+)
  2. Ensure sufficient permissions to run the application
  3. Check Console.app for error messages
  4. Try rebuilding the application

Inaccurate Memory Information

  1. Try manually refreshing memory information
  2. Restart the application
  3. Check for conflicting memory monitoring tools
  4. Verify system integrity with Disk Utility

Notifications Not Appearing

  1. Check System Preferences > Notifications
  2. Ensure the application has notification permissions
  3. Verify memory threshold settings are reasonable
  4. Check "Do Not Disturb" settings

Performance Issues

  1. Increase update interval to reduce CPU usage
  2. Disable notifications if not needed
  3. Check for memory leaks in Console.app
  4. Consider restarting the application

Development

Project Structure

Sources/MemoryPressure/
β”œβ”€β”€ main.swift                    # Application entry point
β”œβ”€β”€ AppDelegate.swift             # Application delegate
β”œβ”€β”€ StatusBarController.swift     # Menu bar controller
β”œβ”€β”€ MemoryMonitor.swift          # Memory monitoring core
β”œβ”€β”€ ConfigurationManager.swift    # Configuration management
β”œβ”€β”€ SettingsWindowController.swift # Settings window controller
└── LocalizationManager.swift    # Multi-language support

Core Components

  • MemoryMonitor: Retrieves system memory information and pressure status
  • StatusBarController: Manages menu bar display and user interactions
  • ConfigurationManager: Handles user preferences and settings
  • SettingsWindowController: Provides graphical settings interface
  • LocalizationManager: Manages multi-language support

Building from Source

  1. Prerequisites:

    • Xcode 15.0 or later
    • macOS 13.0 or later
    • Swift 5.9 or later
  2. Clone and Build:

    git clone https://github.com/yourusername/memory-pressure.git
    cd memory-pressure
    swift build
  3. Run Tests:

    swift test
  4. Create Release Build:

    swift build -c release

Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Adding New Features

To add new functionality:

  1. Add new configuration options in ConfigurationManager
  2. Update the settings UI in SettingsWindowController
  3. Implement the feature logic in the appropriate component
  4. Add localization strings for all supported languages
  5. Update documentation and tests

API Reference

MemoryMonitor

class MemoryMonitor {
    func getCurrentMemoryUsage() -> MemoryInfo
    func getMemoryPressure() -> MemoryPressureLevel
    func startMonitoring(interval: TimeInterval)
    func stopMonitoring()
}

ConfigurationManager

class ConfigurationManager {
    func loadConfiguration() -> Configuration
    func saveConfiguration(_ config: Configuration)
    func exportConfiguration() -> Data
    func importConfiguration(from data: Data)
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • Built with Swift and AppKit
  • Uses macOS system APIs for memory monitoring
  • Inspired by various system monitoring tools
  • Thanks to all contributors and users

Support

If you encounter any issues or have questions:

  1. Check the Troubleshooting section
  2. Search existing Issues
  3. Create a new issue with detailed information
  4. Join our community discussions

Changelog

v1.0.0 (Latest)

  • Initial release
  • Basic memory monitoring functionality
  • Menu bar display with color-coded status
  • Configurable update intervals and display formats
  • Settings window with comprehensive options
  • Multi-language support (5 languages)
  • Notification system for memory alerts
  • Configuration export/import
  • Launch at login support

Memory Pressure Monitor - Keep your Mac running smoothly with real-time memory monitoring.

About

A lightweight macOS menu bar application that provides real-time memory usage monitoring with intelligent alerts and customizable display options.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors