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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Source

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

ShadowPwn
Security Researcher
MEMBER
Rep: 150
Join Date: Feb 2024
Posts: 19
Thanks: 35
6y ago · Jul 1, 2020 8:30 PM
#1
Here is a generic lock-free ObjectPool<T> in C# for reusing expensive game entities and memory streams without GC pressure.
ShadowPwn · Security & Anticheat Analysis
The following users thanked ShadowPwn for this post:
ByteSurgeon
Cheat Engine Specialist
MEMBER
Rep: 140
Join Date: Mar 2025
Posts: 19
Thanks: 30
6y ago · Jul 2, 2020 1:01 AM
#2
Pre-warming the pool on startup with 100 instances completely eliminated GC collections during active combat gameplay!
ByteSurgeon | Cheat Engine & Lua Automation
StructMapper
SDK & Class Builder
MEMBER
Rep: 160
Join Date: May 2024
Posts: 26
Thanks: 39
6y ago · Jul 2, 2020 3:01 AM
#3
Make sure to reset the object state in Return() so previous data does not leak into the next rented instance.
StructMapper | ReClass.NET & Class Layouts