MemoryPressureDetector constructor
MemoryPressureDetector({
- DateTime clock()?,
- int warmupDurationMs = 3000,
- int growthThresholdBytesPerSec = 512000,
- double capacityThresholdPercent = 0.80,
- int? memoryBudgetBytes,
- int gcRateThresholdPerMin = _defaultGcRateThresholdPerMin,
- bool captureMode = false,
- int floorStartupWindowMs = 30000,
- int floorCycleGapMs = 100,
- int floorWindowMs = 60000,
- int floorMinPoints = 3,
- int floorMinSpanMs = 10000,
- int floorFreshnessMs = 30000,
Implementation
MemoryPressureDetector({
DateTime Function()? clock,
this.warmupDurationMs = 3000,
this.growthThresholdBytesPerSec = 512000,
this.capacityThresholdPercent = 0.80,
this.memoryBudgetBytes,
this.gcRateThresholdPerMin = _defaultGcRateThresholdPerMin,
this.captureMode = false,
this.floorStartupWindowMs = 30000,
int floorCycleGapMs = 100,
int floorWindowMs = 60000,
int floorMinPoints = 3,
int floorMinSpanMs = 10000,
int floorFreshnessMs = 30000,
}) : assert(
memoryBudgetBytes == null || memoryBudgetBytes > 0,
'memoryBudgetBytes must be positive when set.',
),
_clock = clock ?? DateTime.now,
super(
type: DetectorType.memoryPressure,
lifecycle: DetectorLifecycle.vmOnly,
name: 'Memory Pressure',
description:
'Detects memory pressure from GC frequency and heap trends',
) {
_floor = HeapFloorTracker(
thresholdBytesPerSec: growthThresholdBytesPerSec,
cycleGapMs: floorCycleGapMs,
windowMs: floorWindowMs,
minPoints: floorMinPoints,
minSpanMs: floorMinSpanMs,
freshnessMs: floorFreshnessMs,
);
_floorStartupBoundaryMs =
_clock().millisecondsSinceEpoch + floorStartupWindowMs;
_floor.clear(notBeforeMs: _floorStartupBoundaryMs);
}