Home / Forums / Fast Object Pooling implementation in C# with ConcurrentBag / Stack [Discussion #7]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

Fast Object Pooling implementation in C# with ConcurrentBag / Stack [Discussion #7]

Algorithmic
Math & Algorithms
MEMBER
Rep: 45
Join Date: Jan 2020
Posts: 6
Thanks: 55
6y ago · Jan 19, 2020 10:48 AM
#1
Here is a generic lock-free ObjectPool<T> in C# for reusing expensive game entities and memory streams without GC pressure.
Algorithmic · Math & Algorithms
Linear algebra, pathfinding, binary spatial partitioning, an...
The following users thanked Algorithmic for this post:
ShaderGuru
HLSL & GLSL Shader Dev
MEMBER
Rep: 219
Join Date: May 2024
Posts: 6
Thanks: 62
6y ago · Jan 19, 2020 2:29 PM
#2
Pre-warming the pool on startup with 100 instances completely eliminated GC collections during active combat gameplay!
ShaderGuru · HLSL & GLSL Shader Dev
Post-processing shaders, stencil buffer tricks, and screen-s...
ImGuiArtist
Modern UI Designer
MEMBER
Rep: 227
Join Date: Dec 2025
Posts: 6
Thanks: 63
6y ago · Jan 20, 2020 7:29 PM
#3
Make sure to reset the object state in Return() so previous data does not leak into the next rented instance.
ImGuiArtist · Modern UI Designer
Dark glassmorphism, animated sliders, and custom font render...