leak_tracker library

Classes

AutoSnapshottingConfig
Configures auto-snapshotting, based on the value of ProcessInfo.currentRss (dart:io).
ContextKeys
LeakDiagnosticConfig
Configuration for diagnostics.
LeakProvider
LeakReport
Leak information, passed from application to DevTools and than extended by DevTools after deeper analysis.
Leaks
Detailed information about found leaks.
LeakSummary
Statistical information about found leaks.
LeakTrackingConfiguration
LeakTrackingTestConfig
Configuration for leak tracking in unit tests.
MemoryUsageEvent
A record of a memory usage event.
SnapshotEvent
A record of a taken snapshot.
UsageEventsConfig
Configures memory usage tracking.
UsageTrackingConfig
Configures memory usage tracking.

Enums

LeakType

Properties

autoSnapshotter ↔ AutoSnapshotter?
getter/setter pair
collectDebugInformationForLeaks bool
If true, the leak tracker will collect debug information for leaks.
getter/setter pair
timer Timer?
getter/setter pair
usageEventCreator ↔ UsageEventCreator?
getter/setter pair

Functions

checkLeaks() Future<LeakSummary>
Checks for leaks and outputs LeakSummary as configured.
checkNonGCed() Future<void>
Checks for new not GCed leaks.
collectLeaks() Future<Leaks>
Returns details of the leaks collected since last invocation.
disableLeakTracking() → void
Disables leak tracking for the application.
dispatchObjectCreated({required String library, required String className, required Object object, Map<String, dynamic>? context}) → void
Dispatches object creation to the leak tracker.
dispatchObjectDisposed({required Object object, Map<String, dynamic>? context}) → void
Dispatches object disposal to the leak tracker.
dispatchObjectEvent(Map<Object, Map<String, Object>> event) → void
Dispatches an object event to the leak tracker.
dispatchObjectTrace({required Object object, Map<String, dynamic>? context}) → void
Dispatches additional context information to the leak tracker.
enableLeakTracking({LeakTrackingConfiguration? config, bool resetIfAlreadyEnabled = false}) → void
Enables leak tracking for the application.
forceGC({Duration? timeout, int fullGcCycles = 1}) Future<void>
Forces garbage collection by aggressive memory allocation.
formattedRetainingPath(WeakReference<Object> ref) Future<String?>
Returns nicely formatted retaining path for the ref.target.
stopMemoryUsageTracking() → void
Stops memory usage tracking if it is started by trackMemoryUsage.
trackMemoryUsage(UsageTrackingConfig config) → void
Enables memory usage tracking, based on the value of ProcessInfo.currentRss (dart:io).
withLeakTracking(DartAsyncCallback? callback, {bool shouldThrowOnLeaks = true, Duration? timeoutForFinalGarbageCollection, LeakDiagnosticConfig leakDiagnosticConfig = const LeakDiagnosticConfig(), AsyncCodeRunner? asyncCodeRunner}) Future<Leaks>
Runs callback with memory leak detection.

Typedefs

AsyncCodeRunner = Future<void> Function(DartAsyncCallback )
DartAsyncCallback = Future<void> Function()
Asynchronous callback.
LeaksCallback = void Function(Leaks leaks)
Handler to collect leak information.
LeakSummaryCallback = void Function(LeakSummary)
Handler to collect leak summary.
SnapshotCallback = void Function(SnapshotEvent event)
A callback that is called when a snapshot is taken.
UsageCallback = void Function(MemoryUsageEvent event)
A callback that is called for memory usage event.

Exceptions / Errors

MemoryLeaksDetectedError