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

discontinued
PlatformAndroidiOS

Opt-in memory diagnostics for flutter_gemma 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_gemma_diagnostics/flutter_gemma_diagnostics.dart';

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

  final before = await FlutterGemmaDiagnostics.memorySnapshot();
  // ... load a model or run a generation here ...
  final after = await FlutterGemmaDiagnostics.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');
}
1
likes
150
points
252
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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

Topics

#memory #diagnostics #gemma #on-device

License

MIT (license)

Dependencies

ffi, flutter, meta

More

Packages that depend on flutter_gemma_diagnostics