PoolerService is a Roblox module for pooling instances to help avoid constant instance Destroy() and Clone() usage which hurts performance in large scale systems.
Key features:
- Get pool, add pool, delete pool
- Pool modification - delete/take/add/get objects in pool
Quick memory test - Creating 10,000 parts and then destroying all after 3 seconds every 8 seconds vs using PoolerService module:
local PoolerService = require(Path.to.PoolerService)
-- // Create your pool:
local MyPool = PoolerService.CreatePool("MyPoolName")
-- // Getting an already existing pool:
local MyPool = PoolerService.GetPool("MyPoolName")
-- // Delete your pool:
PoolerService.DeletePool(MyPool)
-- // Clear all objects from your pool:
PoolerService.ClearPool(MyPool)local PoolerService = require(Path.to.PoolerService)
-- // Create your pool and instance(s)
local MyPool = PoolerService.CreatePool("MyPoolName")
local Part = Instance.new("Part")
Part.Name = "MyPart"
-- // Add an object to the pool:
PoolerService.AddObject(MyPool, Part)
-- // Get an object from a pool:
local Object = PoolerService.GetObject(MyPool, "MyPart")
-- // Take an object from the pool (removes from pool and re-parents it):
PoolerService.TakeObject(MyPool, Object, game.Workspace)
-- // Destroy an object completely (removes from pool and destroys it):
PoolerService.DestroyObject(MyPool, Object)