/**
 * Resource Leak Detection System
 * Monitors and prevents resource leaks in the application
 */
import { EventEmitter } from 'events';
interface LeakDetectionOptions {
    trackingEnabled?: boolean;
    maxAge?: number;
    checkInterval?: number;
    maxResources?: number;
    enableStackTrace?: boolean;
    resourceTypes?: string[];
}
export interface LeakReport {
    resourceType: string;
    leakedCount: number;
    oldestLeak: {
        id: string;
        age: number;
        stackTrace?: string;
    };
    totalMemoryImpact: number;
    recommendations: string[];
}
export declare class ResourceLeakDetector extends EventEmitter {
    private trackedResources;
    private resourceCounts;
    private leakCheckTimer?;
    private options;
    private startTime;
    constructor(options?: LeakDetectionOptions);
    /**
     * Track a new resource
     */
    trackResource(id: string, type: string, metadata?: any): void;
    /**
     * Mark a resource as released
     */
    releaseResource(id: string): void;
    /**
     * Check for resource leaks
     */
    checkForLeaks(): LeakReport[];
    /**
     * Get current resource statistics
     */
    getResourceStats(): {
        totalTracked: number;
        byType: {
            [type: string]: number;
        };
        potentialLeaks: number;
        oldestResource: {
            id: string;
            type: string;
            age: number;
        } | null;
        memoryUsage: number;
    };
    /**
     * Force cleanup of all tracked resources (emergency)
     */
    forceCleanupAll(): number;
    /**
     * Get detailed leak analysis
     */
    getLeakAnalysis(): {
        summary: {
            totalLeaks: number;
            leakRate: number;
            criticalTypes: string[];
        };
        details: Array<{
            resourceId: string;
            type: string;
            age: number;
            stackTrace?: string;
            severity: 'low' | 'medium' | 'high' | 'critical';
        }>;
        recommendations: string[];
    };
    /**
     * Start periodic leak detection
     */
    private startLeakDetection;
    /**
     * Stop leak detection
     */
    private stopLeakDetection;
    /**
     * Capture stack trace for debugging
     */
    private captureStackTrace;
    /**
     * Estimate memory impact of leaked resources
     */
    private estimateMemoryImpact;
    /**
     * Generate recommendations based on leak type
     */
    private generateRecommendations;
    /**
     * Calculate leak severity based on age and type
     */
    private calculateLeakSeverity;
    /**
     * Generate system-wide recommendations
     */
    private generateSystemRecommendations;
    /**
     * Enable or disable tracking
     */
    setTrackingEnabled(enabled: boolean): void;
    /**
     * Shutdown leak detector
     */
    shutdown(): void;
}
export declare function getGlobalResourceLeakDetector(options?: LeakDetectionOptions): ResourceLeakDetector;
export declare function shutdownGlobalResourceLeakDetector(): void;
/**
 * Decorator for automatic resource tracking
 */
export declare function trackResource<T extends (...args: any[]) => any>(resourceType: string, getResourceId?: (result: ReturnType<T>) => string): (target: any, propertyName: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
export {};
//# sourceMappingURL=resource-leak-detector.d.ts.map