flutter_edge_ai_diagnostics 0.1.0 copy "flutter_edge_ai_diagnostics: ^0.1.0" to clipboard
flutter_edge_ai_diagnostics: ^0.1.0 copied to clipboard

Opt-in memory diagnostics for flutter_edge_ai apps: the memory the OS cannot reclaim and the memory still available, read from the OS on Android and iOS.

example/example.dart

// ignore_for_file: avoid_print
import 'package:flutter_edge_ai_diagnostics/flutter_edge_ai_diagnostics.dart';

/// Measures what an operation costs in memory the OS enforces.
Future<void> main() async {
  if (!FlutterEdgeAiDiagnostics.isSupported) {
    print('Memory diagnostics run on Android and iOS only.');
    return;
  }

  final before = await FlutterEdgeAiDiagnostics.memorySnapshot();
  // ... load a model or run a generation here ...
  final after = await FlutterEdgeAiDiagnostics.memorySnapshot();

  final anonBefore = before.anonymousBytes;
  final anonAfter = after.anonymousBytes;
  if (anonBefore != null && anonAfter != null) {
    final mib = (anonAfter - anonBefore) / (1024 * 1024);
    print('Anonymous footprint changed by ${mib.toStringAsFixed(1)} MiB');
  }
  print('Available now: ${after.availableBytes ?? 'unknown'} bytes');
}
0
likes
160
points
83
downloads

Documentation

API reference

Publisher

verified publishersashadenisov.dev

Weekly Downloads

Opt-in memory diagnostics for flutter_edge_ai apps: the memory the OS cannot reclaim and the memory still available, read from the OS on Android and iOS.

Homepage
Repository (GitHub)
View/report issues

Topics

#memory #diagnostics #gemma #on-device

License

MIT (license)

Dependencies

ffi, flutter, meta

More

Packages that depend on flutter_edge_ai_diagnostics