ffi_leak_tracker
0.1.2, released 7 months ago by halildurmus.dev
Tracks and detects native memory leaks in Dart FFI allocations.
What it does
It records every allocation made through its custom allocators, storing size, type, call stack, and timestamp. You can then assert that all memory has been freed or inspect live allocations programmatically.
AI-written summary of version 0.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Debugging FFI memory usage
- Testing for leaks in unit or integration tests
- Diagnosing production memory leaks in debug builds
Skip it when
- When you need zero runtime overhead in release builds, although adaptive allocators compile away
Strengths
- Zero overhead in release builds via adaptive allocators
- Zone‑scoped tracking for isolated tests
- Simple API with global or zone enable/disable
Weaknesses
- Only tracks FFI allocations, not Dart heap allocations
- Requires Dart SDK 3.10 or newer
Setup
- Kind
- FFI (native library)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'dart:ffi';
import 'package:ffi_leak_tracker/ffi_leak_tracker.dart';
void main() {
LeakTracker.enableInDebug();
final ptr = adaptiveCalloc<Int32>();
LeakTracker.verifyNoLeaksInDebug();
}Alternatives
Packages that do the same job and could replace ffi_leak_tracker.
- jni
Provides Dart/Flutter bindings to call native Java code via JNI.
90Compare - hooks
Dart API for the JSON-based protocol for package build and link hooks.
86Compare - snowplow_tracker
Flutter package for sending Snowplow analytics events on Android, iOS, and Web.
78Compare - flutter_olm
Builds the native Olm library for Android and iOS to be used via dart:ffi.
40Compare
Works with
Packages commonly used together with ffi_leak_tracker: ones it builds on, ones built on it, and its own family.
- ffiffi_leak_tracker depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- win32Built on ffi_leak_trackerCall common Windows APIs and COM objects directly from Dart using FFI.
- win32_registryBuilt on ffi_leak_trackerType‑safe Dart API for accessing and managing the Windows Registry
- filepicker_windowsBuilt on ffi_leak_trackerWindows file and directory picker using native dialog controls
- win32_clipboardBuilt on ffi_leak_trackerType‑safe Dart API for reading, writing and monitoring the Windows clipboard.