export interface ResourceMetrics { memoryUsage: NodeJS.MemoryUsage; cpuUsage: NodeJS.CpuUsage; uptime: number; activeHandles: number; activeRequests: number; eventLoopDelay?: number; } export interface LeakDetectionResult { hasMemoryLeak: boolean; hasHandleLeak: boolean; hasCpuLeak: boolean; hasEventLoopLag: boolean; recommendations: string[]; metrics: ResourceMetrics; } export interface ResourceThresholds { maxMemoryMB: number; maxHeapUsageMB: number; maxCpuPercent: number; maxActiveHandles: number; maxEventLoopDelayMs: number; memoryGrowthRateMBPerMin: number; } export declare const DEFAULT_THRESHOLDS: ResourceThresholds; /** * Comprehensive Resource Leak Detection System * Monitors system resources and detects potential memory and handle leaks */ export declare class ResourceLeakDetector { private static instance; private thresholds; private metricsHistory; private maxHistorySize; private monitoringInterval?; private startTime; private baselineMemory?; private constructor(); static getInstance(thresholds?: ResourceThresholds): ResourceLeakDetector; /** * Start continuous resource monitoring */ startMonitoring(intervalMs?: number): void; /** * Stop resource monitoring */ stopMonitoring(): void; /** * Collect current resource metrics */ collectResourceMetrics(): ResourceMetrics; /** * Record metrics in history for trend analysis */ private recordMetrics; /** * Detect potential resource leaks */ detectLeaks(): LeakDetectionResult; /** * Detect memory leaks through usage analysis */ private detectMemoryLeak; /** * Detect handle leaks */ private detectHandleLeak; /** * Detect CPU usage issues */ private detectCpuLeak; /** * Detect event loop lag */ private detectEventLoopLag; /** * Calculate memory growth rate in MB per minute */ private calculateMemoryGrowthRate; /** * Calculate growth rate for any numeric array */ private calculateGrowthRate; /** * Calculate approximate CPU percentage */ private calculateCpuPercent; /** * Generate comprehensive resource report */ generateResourceReport(): { status: 'healthy' | 'warning' | 'critical'; summary: string; leakDetection: LeakDetectionResult; trends: { memoryTrend: 'stable' | 'increasing' | 'decreasing'; handleTrend: 'stable' | 'increasing' | 'decreasing'; }; integrationStatus: { memoryManager: any; correlationTracker: any; }; }; /** * Force garbage collection if available (for leak testing) */ forceGarbageCollection(): boolean; /** * Get resource metrics history for analysis */ getMetricsHistory(): ResourceMetrics[]; /** * Clear metrics history (for testing) */ clearHistory(): void; } export declare const resourceLeakDetector: ResourceLeakDetector; /** * Helper function to integrate resource leak detection with graceful shutdown */ export declare function setupGracefulShutdown(): void; //# sourceMappingURL=resourceLeakDetector.d.ts.map