Skip to main content

Pooler

Fast and easy to use instance pooler.

Speedy

Faster than the equivalent Instance.new() calls by ~42% in the best case scenario.

Easy

Easy to use and drop in to your existing codebase. No need to make massive alterations.

Customizable

All the options under the sun, and then some.

Why use an instance pooler?

Take the scenario of a bullet hell game. Think Touhou. These games generally have a lot of objects:

bullets!!!

It's more performant to recycle these objects than destroy and recreate them. Whilst the differences are small, when the time it takes adds up, your game will be a lot slower by removing and creating instances when compared to using an instance pooler.

Why use Pooler?

Pooler is designed to take any instance type and pool it. The majority of poolers I've seen can only accept parts and the ones I've seen that don't do not have much customizability. I wrote Pooler to fill that gap for myself, and now I'm releasing it here.

Needless to say, Pooler is not perfect. There are many improvements that can be made, especially related to returning objects to the pool and what to do on exhaustion. For the majority of tasks, however, Pooler is a suitable library that will handle thousands of objects easily.

Getting Started

Create your Pooler:

local template = Instance.new("Part")

template.Anchored = true

template.Material = Enum.Material.Neon
template.BrickColor = BrickColor.Green()

local pool = Pooler.new(template)

Now, you can fetch instances from it:

local instance = pool:Get()

Once you're done with that instance, just (optionally) return it to the pool again:

pool:Return(instance)