system_resources_2
2.2.2, released 9 months ago by serverpod.dev
Access CPU and memory usage, container-aware, pure Dart on Linux, FFI on macOS
What it does
Provides APIs to read CPU load, CPU limits, memory usage and limits, and detect container environments. It uses cgroup files on Linux and native dylibs on macOS.
AI-written summary of version 2.2.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Need to monitor system resources in a Dart/Flutter app
- Running in containers and want metrics relative to limits
- Cross-platform (Linux/macOS) resource monitoring without native dependencies on Linux
Skip it when
- Running on Windows or unsupported platforms
- You need advanced profiling or GPU metrics
- You need to run on iOS/Android
Strengths
- Pure Dart on Linux eliminates native binaries
- Container-aware with cgroup v1/v2 support
- No external dependencies beyond ffi
- Supports gVisor environments
Weaknesses
- Not supported on Windows, iOS, Android
- Requires macOS dylib for macOS
- No support for other platforms like web or mobile
Setup
- Kind
- FFI (native library)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add dependency, call SystemResources.init() on macOS, no special permissions needed
import 'package:system_resources_2/system_resources_2.dart';
void main() async {
await SystemResources.init();
print('CPU Load: ${(SystemResources.cpuLoadAvg()*100).toInt()}%');
print('Memory Usage: ${(SystemResources.memUsage()*100).toInt()}%');
}Alternatives
Packages that do the same job and could replace system_resources_2.
Works with
Packages commonly used together with system_resources_2: ones it builds on, ones built on it, and its own family.
- ffisystem_resources_2 depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- serverpodBuilt on system_resources_2Serverpod is the ultimate app-stack for agentic coding. It is a complete, open-source solution for your app, backend, website, and database, all using Flutter and Dart.