pub repository
mirror.p-hatan.comffi_leak_tracker
0.1.2Allocation tracking and leak detection for Dart FFI code.
Cached in Iran · Upstream SHA-256 matched
Readme
ci codecov Package: ffi_leak_tracker Publisher: halildurmus.dev Language: Dart License: BSD-3-Clause
Allocation tracking and leak detection for Dart FFI code.
🎯 Overview
package:ffi_leak_tracker helps you find and diagnose native memory leaks in
Dart FFI code by tracking allocations made through its custom allocators.
When tracking is enabled, every allocation is recorded with its size, type, call stack, and timestamp. You can then assert that all memory has been freed, inspect live allocations programmatically, or emit diagnostic reports — making it easy to catch leaks in tests or narrow down where they originate in production.
The package is designed to have no impact on release performance. The adaptive
allocators (adaptiveCalloc(), adaptiveMalloc()) compile away to standard
calloc() and malloc() in release builds, so you can leave them in place
unconditionally.
The diagnostic allocators (diagnosticCalloc(), diagnosticMalloc()) are
available for cases where tracking must remain active regardless of build mode.
Tracking can be enabled globally or scoped to a zone, so you can isolate specific tests or benchmarks without affecting the rest of your application.
⚡ Quick Example
import 'dart:ffi';
import 'package:ffi_leak_tracker/ffi_leak_tracker.dart';
void main() {
// Enable tracking only in debug/profile builds.
LeakTracker.enableInDebug();
print('Allocating memory without freeing it...');
final ptr = adaptiveCalloc<Int32>();
// Fix the leak by uncommenting:
// adaptiveCalloc.free(ptr);
print('Verifying for leaks...');
// In debug builds this throws if any allocations remain.
LeakTracker.verifyNoLeaksInDebug();
print('No leaks detected.');
}
📝 Documentation
Full documentation is available at win32.pub/docs/advanced/leak-tracking.
🐞 Features and Bugs
If you encounter bugs or need additional functionality, please file an issue.
Changelog
Changelog
All notable changes to this project will be documented in this file.
0.1.2 - 2026-04-11
📦 Dependencies
- Lower minimum Dart SDK to 3.10
0.1.1 - 2026-03-06
🎨 Styling
- Improve output of
PrintEmitter - Improve
toString()outputs forAllocationandLeakExceptionclasses
0.1.0 - 2026-02-22
- Initial version.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add ffi_leak_trackerpubspec.yaml
name: ffi_leak_tracker
description: Allocation tracking and leak detection for Dart FFI code.
version: 0.1.2
repository: https://github.com/halildurmus/win32/tree/main/packages/ffi_leak_tracker
issue_tracker: https://github.com/halildurmus/win32/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22package%3A%20ffi_leak_tracker%22
documentation: https://win32.pub/docs/advanced/leak-tracking
funding:
- https://github.com/sponsors/halildurmus
topics:
- interop
- ffi
environment:
sdk: ^3.10.0
resolution: workspace
dependencies:
ffi: ^2.1.4
dev_dependencies:
checks: ^0.3.1
halildurmus_lints: ^1.1.0
test: ^1.27.0
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | 2026-02-22T10:44:07.494413Z | Cached | 076941187786423291bacbbf19017e3e473cf01c9d96fccc869979494f2156cb |
| 0.1.1 | 2026-03-06T15:16:58.287120Z | Cached | 25a58eeab3f50c90b5c8ee734a816af8021777246e3272db296d1d724cc63188 |
| 0.1.2 | 2026-04-11T19:16:04.446365Z | Cached | 4093d4ef9ca06ffe2786e73bfb25e22aa92112b9bb4ec941f11e3e6b61489a97 |
Dependencies
ffi "^2.1.4"