[Released] Fast Pool - Fastest pooling solution

Hello everyone!
There is a good news - Fast Pool has been released on the Asset Store :slight_smile:

As you know, Instantiate / Destroy calls is very expensive and may cause performance problems. Pooling helps to avoid this by re-using created objects, instead of destroying and instantiating it.

Download here: Unity Asset Store - The Best Assets for Game Making

After a long time we search the better pooling solution in the asset store, we found that there is no one that fulfill our requirements. One of them is a very laggy, another has poor functionality. So we decide to write our own solution. Benchmarking and comparing performance with other pooling tools shows that our Fast Pool is the fastest solution in the Asset Store. And we will give a free copy of Fast Pool to the first five users that find much faster solution (with the same functionality).

Main Features:

  • As fast as a flash
  • Great for mobile devices
  • Supports all types of objects
  • Easy integration and intuitive user interface
  • GameObject and Component extensions to make pooling easier
  • OnFastInstantiate and OnFastDestroy events to handle object spawning
  • A lot of helpful examples

Purchase Fast Pool Now

Screenshots:

Does it have a FIFO mode ? ( Despawning the oldest items to make room for the newests)

A webplayer demo to try before buy would be good !

It uses stack to organize despawned objects, so it woks in LIFO mode (First despawned objects will be spawned last).
The trick is to handle only despawned objects. Using FIFO in this case is a bad idea, because it has performance issues (need to rearrange item indexes in the queue every time a new object is added). If despawned objects stack is full (in case you limit its size) and you try to despawn object - it will be simply destroyed rather than added to the pool.

It will be added this week :slight_smile:

Madness SALE!
Fast Pool is now 54% off

You can buy it only for $4.5 !

Buy now !

Could you make a webplayer demo for test before buy ?

Hi there! I’m just converting my project to Fast Pool. Wondering how to FastDestroy() a GameObject instance without knowing its pool? It seems I need to retrieve the pool before being able to do that? I do something like this, but I’m not sure if that’s correct or even gets the right pool.

this.pool = FastPoolManager.GetPool(objectToRemove, false);
if (this.pool != null) {
    this.pool.FastDestroy(objectToRemove);
}
1 Like

To be specific, how do I FastDestroy an instance without knowing pool or prefab. Or do I need to keep track of that myself for all instances?

1 Like

I also got this asset and I was playing with it today.
For what I noticed, if you try to use GetPool() with the instance of the gameObject, it won’t work (I tried it). You will need to get the reference of the Prefab itself somehow. This use the InstanceID to get the right Pool and the ID changes from Prefab to instantiated object.

The other possibility would be to use instance.FastDestroy(Pool); , but how you can notice, in this case you will need the reference of the pool itself.

This shouldn’t be a problem if you use the same script to instantiate and destroy the objects, but I had a generic “Destroy” script and this was an interesting problem to solve without loosing the “generic” part of the script.

At the end I did this:

I created this little script and added to all the prefabs I intended to Destroy using the Pool.

using UnityEngine;

public class Pooleable : MonoBehaviour {
    public FastPool pool;
    public void Destroy(){
        gameObject.FastDestroy(pool);
    }

}

Then to instantiate an object I do this:

var pool = FastPoolManager.GetPool(Prefab);
var pooleable = pool.FastInstantiate<Pooleable>();
pooleable.pool = pool;

In this way, all instances will know from which pool are they.

And finally, I can destroy them from anywhere:

gameObject.GetComponent<Pooleable>().Destroy();

At least is working for me. Would be good if the developer can make this “destroying” easier, In general I found this asset quite useful.

Also for the developer:
I noticed that the counter in the FastPoolManager is not working. It just work in public FastPool properties other than the Manager. At the beginning I thought I was doing something wrong but Im pretty sure now it’s a bug.

1 Like

By the way, If Im wrong, or if there’s a better way to do this, will be nice to know :slight_smile:
I know GetComponent is not the fastest thing to do, but for my use was good enough.

Yeah eToledom, I’m doing the same at the moment. Storing a reference to the prefab on each instance. I’m thinking a reference to the pool - like you are doing - may be more memory-efficient that a reference to the prefab. Need to run a few tests to check that…

1 Like

Hello guys, thanks for your questions :slight_smile:

In most cases objects that can be pooled spawns from the some “manager” script. If you have the same architecture - you can add the public field that holds source prefab in your manager script. And when you need to destroy object - you can use

//if you destroy object from itself)
FastPoolManager.GetPool(YourManagerClass.Instance.Prefab, false).FastDestroy(gameObject);

//or

//if you destroy object from the manager
FastPoolManager.GetPool(Prefab, false).FastDestroy(objectToRemove);

In case if you don’t want to make your manager script singleton, you can create a separate singleton script that will holds all the needed source prefabs.

If you don’t love singletons and don’t want use it - then you can use solution by eToledom.

Hello! Is there any way to make initial pooled objects to be set as children of an specific object?

Hello,
Yes. If you toggle “Parent on Cache” checkmark - all pooled objects will be parented to the object which holds FastPoolManager script. But I don’t recommend to do this, because reparenting is a costly procedure and with a huge amount of objects it can make performance down.

Thanks. Tried that, but it seems it wasn’t parenting them.
It was just due to the fact that all these pooled objects create a big mess on my project :confused:

Check this two minutes ago and it’s working. May be you do something wrong?
Screen 1 (Manager Setup)
Screen 2 (Pooled objects parented to manager’s GO)

I came here with the very same problem…
Improving the package for scenarios with separate spawners and destroyers would really make it more convenient.

Do you know what could cause this bug^

ArgumentException: An element with the same key already exists in the dictionary.
System.Collections.Generic.Dictionary`2[System.Int32,FastPool].Add (Int32 key, .FastPool value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
FastPoolManager.Start () (at Assets/FastPool/Scripts/FastPoolManager.cs:39)

I have an array of prefabs as GameObjects. This spawner object picks random prefab from this list and instantiates it. Instances may or may not maintain original rotation. Not sure if it is valuable.

For some reason this code generates new FastPool even for the same prefab at each Spawn. So I end up having many 1/Infinity Fast Pools. What Am I doing wrong?

private void Spawn()
    {
        GameObject spawned = prefabsToSpawn[Random.Range(0, prefabsToSpawn.Length)];
        Quaternion rotation = spawned.transform.rotation;
        if (ori == SpawnOrientation.RAND)
        {
            rotation = Quaternion.AngleAxis(Random.value*360, Vector3.up);
        }
        FastPool pool = FastPoolManager.GetPool(spawned);
        Pooleable pooleable = pool.FastInstantiate<Pooleable>(this.transform.position, rotation);
        if (pooleable)
        {
            pooleable.pool = pool;
            Spawned(this, pooleable.gameObject);
        }


    }