UNPKG

supa-seed

Version:

A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support

114 lines 2.94 kB
/** * Memory Management and Cleanup System * Phase 6, Checkpoint F1 - Efficient memory usage and automatic cleanup */ export interface MemoryConfig { maxHeapUsageMB: number; cleanupIntervalMs: number; warningThresholdMB: number; forceGCThresholdMB: number; maxCacheSize: number; } export interface MemoryStats { heapUsed: number; heapTotal: number; external: number; arrayBuffers: number; rss: number; usage: { heapUsedMB: number; heapTotalMB: number; externalMB: number; }; percentageUsed: number; recommendations: string[]; } export interface CleanupTask { name: string; priority: 'low' | 'medium' | 'high' | 'critical'; estimatedMemoryFreedMB: number; cleanup: () => Promise<void> | void; condition?: () => boolean; } export declare class MemoryManager { private static config; private static cleanupTasks; private static cleanupInterval; private static memoryHistory; private static isCleaningUp; /** * Initialize memory management system */ static initialize(config?: Partial<MemoryConfig>): void; /** * Register a cleanup task */ static registerCleanupTask(task: CleanupTask): void; /** * Get current memory statistics */ static getMemoryStats(): MemoryStats; /** * Force memory cleanup */ static forceCleanup(reason?: string): Promise<{ beforeMB: number; afterMB: number; freedMB: number; tasksExecuted: string[]; }>; /** * Check if memory cleanup is needed */ static shouldCleanup(): boolean; /** * Set memory limits */ static setMemoryLimits(limits: Partial<MemoryConfig>): void; /** * Get memory usage history */ static getMemoryHistory(minutes?: number): Array<{ timestamp: Date; heapUsedMB: number; heapTotalMB: number; }>; /** * Start memory monitoring */ private static startMemoryMonitoring; /** * Record memory usage for history */ private static recordMemoryUsage; /** * Calculate memory growth rate in MB per minute */ private static calculateMemoryGrowthRate; /** * Register default cleanup tasks */ private static registerDefaultCleanupTasks; /** * Handle process shutdown */ private static handleShutdown; /** * Get cleanup recommendations */ static getCleanupRecommendations(): { urgent: string[]; suggested: string[]; preventive: string[]; }; /** * Clear memory history */ static clearHistory(): void; } /** * Memory monitoring decorator */ export declare function monitorMemory(thresholdMB?: number): (target: any, propertyName: string, descriptor: PropertyDescriptor) => void; export default MemoryManager; //# sourceMappingURL=memory-manager.d.ts.map