This is my first object pooler created in unreal, I wanted something that could be used across any class, and the Shrimple Object Pooler is my solution to that problem.
What makes this object pooler good?
Pre-Allocation with Array Reservation:
Arrays reserve space upfront, based on configured pool sizes, to prevent costly reallocations during initialization.
Efficient Pool Management:
Objects are stored in two arrays per pooled class — an active array and an inactive array. Instead of costly RemoveAt() calls causing array reshuffling, returned objects are set to nullptr in the active array and placed into available slots in the inactive array. This approach minimizes memory reallocations and fragmentation, maintaining stable performance even with large pools.
Interface Enforcement:
Only actors implementing the IPooledObject interface can be pooled, ensuring pooled objects support activation and deactivation hooks. This guarantees that actors correctly reset their state when reused.
Expandable Pools and Fallbacks:
The pool supports dynamic expansion if configured, allowing new objects to spawn when the pool runs out. Additionally, it can be set to reuse the oldest active object, providing flexible object reuse strategies that fit different gameplay needs.
Configurable Per-Class Cleanup:
A cleanup timer periodically compacts pooled arrays by removing invalid or destroyed actor references. This cleanup respects user-configured thresholds and frequencies on a per-class basis, optimizing runtime memory use without causing frame spikes.
Blueprint and Editor Friendly:
Spawned pooled actors are organized under a dedicated editor folder (/Pool) to keep the world outliner tidy. Spawn parameters avoid deferred construction to ensure predictable initialization.