MemoryPressureInjector class
Simulates memory pressure to test how an AI model behaves near or beyond its available RAM budget.
The injector delegates memory allocation to the AIModelAdapter via AIModelAdapter.simulateMemoryPressure, allowing adapters that wrap real native models to trigger actual OS-level memory pressure if desired.
Usage
final injector = MemoryPressureInjector(
model: myAdapter,
limitMb: 150,
);
await injector.inject(); // allocates 150 MB
// … run inference …
await injector.reset(); // releases memory
- Implemented types
Constructors
- MemoryPressureInjector({required AIModelAdapter model, int limitMb = 100})
-
Creates a MemoryPressureInjector.
const
Properties
- description → String
-
Detailed description of what this injector simulates.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- limitMb → int
-
Amount of memory (in MB) to allocate during inject.
final
- model → AIModelAdapter
-
The model adapter to stress.
final
- name → String
-
Short human-readable name shown in reports and logs.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → FaultType
-
The FaultType category this injector belongs to.
no setteroverride
Methods
-
inject(
) → Future< void> -
Activate the fault.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → Future< void> -
Deactivate the fault and restore normal conditions.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited