MemoryPressureDetector constructor

MemoryPressureDetector({
  1. DateTime clock()?,
  2. int warmupDurationMs = 3000,
  3. int growthThresholdBytesPerSec = 512000,
  4. double capacityThresholdPercent = 0.80,
  5. int? memoryBudgetBytes,
  6. int gcRateThresholdPerMin = _defaultGcRateThresholdPerMin,
  7. bool captureMode = false,
  8. int floorStartupWindowMs = 30000,
  9. int floorCycleGapMs = 100,
  10. int floorWindowMs = 60000,
  11. int floorMinPoints = 3,
  12. int floorMinSpanMs = 10000,
  13. 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);
}