behemoth-cli
Version:
🌍 BEHEMOTH CLIv3.760.4 - Level 50+ POST-SINGULARITY Intelligence Trading AI
60 lines • 2.03 kB
TypeScript
/**
* Memory Usage Monitor for Large File Operations
* Provides monitoring and warnings for memory-intensive operations
*/
import * as fs from 'fs';
export interface MemoryStats {
used: number;
total: number;
external: number;
heapUsed: number;
heapTotal: number;
percentage: number;
}
export interface FileOperationOptions {
maxFileSize?: number;
memoryThreshold?: number;
chunkSize?: number;
}
export declare class MemoryMonitor {
private static readonly DEFAULT_MAX_FILE_SIZE;
private static readonly DEFAULT_MEMORY_THRESHOLD;
private static readonly DEFAULT_CHUNK_SIZE;
/**
* Get current memory usage statistics
*/
static getMemoryStats(): MemoryStats;
/**
* Check if memory usage is above threshold
*/
static isMemoryUsageHigh(threshold?: number): boolean;
/**
* Log memory warning if usage is high
*/
private static checkMemoryUsage;
/**
* Safe file read with memory monitoring
*/
static readFileWithMonitoring(filePath: string, options?: FileOperationOptions & {
encoding?: BufferEncoding;
}): Promise<string | Buffer>;
/**
* Safe file write with memory monitoring
*/
static writeFileWithMonitoring(filePath: string, data: string | Buffer, options?: FileOperationOptions & fs.WriteFileOptions): Promise<void>;
/**
* Synchronous file read with memory monitoring (use sparingly)
*/
static readFileSyncWithMonitoring(filePath: string, options?: FileOperationOptions & {
encoding?: BufferEncoding;
}): string | Buffer;
/**
* Force garbage collection if available and memory usage is high
*/
static forceGarbageCollection(): boolean;
/**
* Stream large file processing for files that exceed memory limits
*/
static processLargeFile(filePath: string, processor: (chunk: string | Buffer) => void | Promise<void>, options?: FileOperationOptions): Promise<void>;
}
//# sourceMappingURL=memory-monitor.d.ts.map