Object pooling for every device

Desktop, Laptop, Tablet, Mobile, Console

What is Object Pooling?

A simple and effective optimisation, for game programming and other high performance situations. Use Pure Pool to ensure a smooth and responsive game.

Pure Pool is the only fully-serialisable object pool for Unity software. Pools, all of their settings, and all of their statistics, are all serialisable. Make the most of the ability to hot reload code (also called live recompilation) for rapid prototyping and iterative development, without losing your pools in the process.

Features

High-performance

Avoid the overheads of garbage collection. Lightning fast instantiation and destruction due to recycling of objects.

Statistics

Monitor your pools in real-time. View in the inspector or access through code, and ensure your pools are performing optimally. Recommended pool size helps you avoid generating garbage.

Recycling

Re-use your Unity game objects and regular C# objects. Simply reset their values when you take them from the pool, and never instantiate again.

Optimised Code

Powerful C# API and performance-tested code. Create, modify, and delete pools at runtime. Acquire and release hundreds of objects per frame.

Source Code

Fully-commented and documented source code. Visual Studio 2019 solution included. Conditional compilation allows disabling of unwanted features.

Customisable

Change pool settings in the inspector or from code. Initial size, maximum size, notification modes, events - and much more.

Custom Inspector

Custom inspectors give you great power at your fingertips. Drag and drop to create pools, organise them within nested containers, and search using regular expressions. Undo support and prefab overrides, as expected.

Networking Support

Integration libraries and scripts for Unity 5+ Networking (UNet), Mirror Networking, and Photon Unity Networking (PUN Classic, PUN2, and Photon Bolt) help make object pooling simple, even for networked games.

PlayMaker Support

An integration library is included with PlayMaker actions, to help you use object pooling in your FSMs - without needing any programming knowledge.

Code Examples

Create a Pool


// Create the pool for the asteroids.
this.PoolManager.CreatePool(new GameObjectPoolSettings {
	Source = this.Asteroid,
	InitialSize = 85,
	MaximumSize = 100,
	InitialiseOnStart = true,
	LogMessages = LogLevel.Information,
	DontDestroyOnLoad = false
});

Creating a new pool at runtime is easy. The provided GameObjectPoolSettings class has sensible default values and can be changed as required.

Create a Serialisable Custom Pool


// Subclass SerialisableObjectPool to create your own serialisable pool for any type.
[Serializable]
public class MyCustomClassObjectPool : SerialisableObjectPool<MyCustomClass> { }

[SerializeField, HideInInspector]
private MyCustomClassObjectPool pool;

// Set up the pool in your Awake or Start method.
this.pool = new MyCustomClassObjectPool {
	InitialSize = 10,
	MaximumSize = 100,
	InstantiateWhenEmpty = false
};

// Call initialise when your pool is set up. It's now ready to use!
this.pool.Initialise();

Create a serialisable pool for any type. The pool will survive assembly reloads and allows for quick prototyping.

Object.Instantiate Replacement


// Acquire (pool-based replacement for Instantiate) an asteroid.
this.PoolManager.Acquire(this.Asteroid, position, Random.rotation, this.transform);

// Instead of the original:
Object.Instantiate(this.Asteroid, position, Random.rotation, this.transform);

Swapping out Instantiate for the pool-based Acquire is as easy as using Find-and-Replace. Access the Manager statically through PoolManager.Instance.

Object.Destroy Replacement


// Release (pool-based replacement for Destroy) the asteroid.
this.PoolManager.Release(this.gameObject);

// Instead of the original:
Object.Destroy(this.gameObject);

As with Instantiate, replacing Destroy is as simple as using the Release method on the Manager.

For further code samples and tutorials, see the online documentation for Pure Pool and the API reference.