/** * Memory Pooling Utilities * Reuse objects and arrays to reduce GC pressure and improve performance * How does this work? */ /** * Generic object pool for reusing objects * Reduces garbage collection overhead by 30-50% */ export declare class ObjectPool { private pool; private factory; private reset?; private maxSize; constructor(factory: () => T, maxSize?: number, reset?: (obj: T) => void); /** * Get an object from the pool or create a new one */ acquire(): T; /** * Return an object to the pool for reuse */ release(obj: T): void; /** * Clear the pool */ clear(): void; /** * Get current pool size */ size(): number; } /** * Array pool for reusing arrays * Particularly useful for temporary arrays in hot paths * Note: size parameter is just a hint for pool organization */ export declare class ArrayPool { private pool; private maxSize; constructor(maxSize?: number); /** * Get an array from the pool (size is just a hint for organization) */ acquire(_size?: number): T[]; /** * Return an array to the pool for reuse */ release(arr: T[]): void; /** * Clear the pool */ clear(): void; /** * Get total number of pooled arrays */ size(): number; } /** * Global array pool for common operations */ export declare const globalArrayPool: ArrayPool; /** * Helper to use pooled array with automatic cleanup */ export declare function withPooledArray(size: number, fn: (arr: T[]) => R): R; /** * Map pool for reusing Map objects */ export declare class MapPool { private pool; private maxSize; constructor(maxSize?: number); /** * Get a Map from the pool */ acquire(): Map; /** * Return a Map to the pool for reuse */ release(map: Map): void; /** * Clear the pool */ clear(): void; /** * Get current pool size */ size(): number; } /** * Set pool for reusing Set objects */ export declare class SetPool { private pool; private maxSize; constructor(maxSize?: number); /** * Get a Set from the pool */ acquire(): Set; /** * Return a Set to the pool for reuse */ release(set: Set): void; /** * Clear the pool */ clear(): void; /** * Get current pool size */ size(): number; } /** * Global pools for common use cases */ export declare const globalMapPool: MapPool; export declare const globalSetPool: SetPool; //# sourceMappingURL=memory-pool.d.ts.map