/**
 * Memory Optimizer
 * Advanced memory management for streaming data analysis
 */
import { EventEmitter } from 'events';
export interface MemoryOptimizationOptions {
    maxMemoryMB?: number;
    gcThresholdMB?: number;
    memoryCheckInterval?: number;
    enableMemoryPooling?: boolean;
    bufferPoolSize?: number;
    adaptiveChunkSizing?: boolean;
    memoryPressureThreshold?: number;
}
export interface MemoryStats {
    heapUsed: number;
    heapTotal: number;
    external: number;
    rss: number;
    arrayBuffers: number;
}
export interface ChunkSizeRecommendation {
    recommendedSize: number;
    reason: string;
    memoryPressure: number;
    adaptationFactor: number;
}
/**
 * Advanced memory optimizer with adaptive streaming
 */
export declare class MemoryOptimizer extends EventEmitter {
    private options;
    private bufferPool;
    private memoryCheckTimer?;
    private memoryHistory;
    private isMonitoring;
    private lastGcTime;
    private baselineMemory;
    constructor(options?: MemoryOptimizationOptions);
    /**
     * Start memory monitoring
     */
    startMonitoring(): void;
    /**
     * Stop memory monitoring
     */
    stopMonitoring(): void;
    /**
     * Get current memory statistics
     */
    getCurrentMemoryStats(): MemoryStats;
    /**
     * Calculate memory pressure (0-1 scale)
     */
    getMemoryPressure(): number;
    /**
     * Get adaptive chunk size recommendation
     */
    getAdaptiveChunkSize(baseChunkSize: number, dataComplexity?: number): ChunkSizeRecommendation;
    /**
     * Get or create buffer with memory pooling
     */
    getBuffer(size: number): Buffer;
    /**
     * Return buffer to pool
     */
    returnBuffer(buffer: Buffer): void;
    /**
     * Force garbage collection if possible and beneficial
     */
    forceGarbageCollection(): boolean;
    /**
     * Check memory usage and take action if needed
     */
    private checkMemoryUsage;
    /**
     * Calculate memory usage trend (MB per second)
     */
    private calculateMemoryTrend;
    /**
     * Get comprehensive memory statistics
     */
    getDetailedStats(): {
        current: MemoryStats;
        baseline: MemoryStats;
        memoryGrowth: {
            heapUsed: number;
            heapTotal: number;
            rss: number;
        };
        pressure: {
            level: number;
            threshold: number;
            status: string;
        };
        trend: {
            mbPerSecond: number;
            direction: string;
        };
        bufferPool: {
            totalBuffersCreated: number;
            totalBuffersReused: number;
            reuseRate: string;
            buffersInPool: number;
            poolSizes: {
                [k: string]: number;
            };
        };
        monitoring: {
            isActive: boolean;
            interval: number;
            historySize: number;
        };
    };
    /**
     * Clean up resources
     */
    cleanup(): void;
}
/**
 * Get or create global memory optimizer
 */
export declare function getGlobalMemoryOptimizer(options?: MemoryOptimizationOptions): MemoryOptimizer;
/**
 * Shutdown global memory optimizer
 */
export declare function shutdownGlobalMemoryOptimizer(): void;
/**
 * Memory optimization decorator for async functions
 */
export declare function withMemoryOptimization<T extends (...args: any[]) => Promise<any>>(fn: T, options?: {
    enableGc?: boolean;
    bufferPooling?: boolean;
    memoryThreshold?: number;
}): T;
//# sourceMappingURL=memory-optimizer.d.ts.map