In Otter's Hell, everyone shoots. Sparkles, the protagonist, fires projectiles nonstop. Enemies answer with their own. Turrets and environmental traps fill the room with bullets even when nobody is nearby, and bosses are designed precisely around that idea: patterns of hundreds of projectiles that the player has to read, learn and dodge. It's a bullet hell roguelite, and in a bullet hell the bullet is by far the most common object in the game.
This article is a post-mortem of a very specific part of the project: how we handled the creation and destruction of all those objects. Not the whole game, just this system. From the simplest approach (Instantiate when firing, Destroy on hit) to a bullet pooling system that we later extended (and, in some cases, removed because it added nothing).
We'll cover the problems that creating and destroying many objects can cause, the switch to an Object Pool that manages them, what breaks when you recycle objects and, above all, how to decide what deserves a pool and what doesn't.
1. A Bullet Hell Is an Object Factory
In most games, creating an object is a one-off event: an enemy appears, a menu opens, a chest drops. In a bullet hell it's the normal state of play. In a room with several enemies, a couple of turrets and a player with multiple upgrades, projectiles are being born and dying every single frame. Add the roguelite layer on top, and the bullets on screen scale with the run, the player's build, and the number of enemies and their patterns.
In Otter's Hell there were, broadly speaking, four sources of projectiles:
- Player: Weapon upgrades combined with items. The same weapon can fire in a spread, shoot projectiles that split on impact, fast bursts of bullets...
- Enemies: Each with its own complex pattern. More enemies, more bullets.
- Environment: Turrets and traps that fire on their own, also with their own patterns.
- Bosses: Designed around patterns that cover the whole screen and are hard to dodge. But the more complex the pattern, the more projectiles it needs.
And it's not just the projectile itself. Every shot also had to carry an impact effect. Some could also trigger an explosion, and sometimes a damage area dropped beneath the player. A bullet wasn't one object; it was the start of a chain of them.
2. The First Version: Instantiate and Destroy
At first, every bullet was instantiated when fired and destroyed on hit or when its lifetime ran out. For a prototype, that's perfectly fine. But the further the project goes, the more content shows up on screen. And that ends up reflected in the game's performance.
To understand why, you need to know what each call does in Unity. Instantiate is not a new. Under the hood, Unity clones the native object (the GameObject, its Transform, every component), copies the prefab's values into the new object, registers the components with the relevant systems (physics, rendering, animation) and runs Awake and OnEnable on every script. If the prefab has a Rigidbody and a collider, that collider is added to the physics scene. If it has a TrailRenderer or a ParticleSystem, those get initialized too.
And all of this happens on the main thread.
Destroy isn't as simple as deleting an object either. The actual destruction is deferred to the end of the frame, where OnDisable and OnDestroy run, the components are removed from each system and the native part is freed. The managed part (the C# object wrapping the native one) stays on the heap (a region of memory) as garbage until the Garbage Collector (GC) comes by to free it. As I explained in the profiling article, when the GC runs, the main thread stops. A single bullet doesn't produce much garbage, but hundreds per second, plus everything allocated around them, fill the heap and trigger collections every so often. That's what causes those annoying frame drops.
1public class Weapon : MonoBehaviour
2{
3 [SerializeField] Bullet bulletPrefab;
4 [SerializeField] Transform muzzle;
5
6 // The first version: one Instantiate per shot.
7 public void Fire()
8 {
9 Bullet bullet = Instantiate(bulletPrefab, muzzle.position, muzzle.rotation);
10 bullet.Launch(muzzle.forward);
11 }
12}
13
14public class Bullet : MonoBehaviour
15{
16 [SerializeField] float speed = 20f;
17 [SerializeField] float lifetime = 3f;
18
19 public void Launch(Vector3 direction)
20 {
21 GetComponent<Rigidbody>().linearVelocity = direction * speed;
22 Destroy(gameObject, lifetime); // and one Destroy per bullet
23 }
24
25 void OnTriggerEnter(Collider other)
26 {
27 // ... apply damage, spawn the impact effect ...
28 Destroy(gameObject);
29 }
30}Multiplied by the four sources of projectiles, and then by every effect each impact spawned, that innocent-looking code was a machine for generating work for the engine and garbage for the GC.
3. Measure First
The temptation at that point is to pool everything. If it saves resources, it must always be a good idea. However, it's important to keep in mind that every pool has to be justified by a measurement. In Unity's Profiler, with the CPU Usage module and the Hierarchy view, there are three things to look at:
- A
GC.Collectmarker taking several milliseconds in the frames that stutter. It means the accumulated garbage is a problem. - The
GC Alloccolumn in normal frames. The firing method shouldn't show up allocating memory for every bullet. - The cost of
Instantiateitself. If the prefab is heavy (many components, children, particles), creating the object already eats time even when the GC is quiet.
To know exactly who is allocating, the Timeline view lets you enable call stacks for GC.Alloc samples. That way you don't need Deep Profile, which instruments every method and distorts timings so much that it's only useful for seeing proportions. Once you have a suspect, a ProfilerMarker around the specific code gives much more reliable numbers.
1using Unity.Profiling;
2using UnityEngine;
3
4public class Weapon : MonoBehaviour
5{
6 static readonly ProfilerMarker s_FireMarker = new("Weapon.Fire");
7
8 public void Fire()
9 {
10 using (s_FireMarker.Auto())
11 {
12 // ... Instantiate or pool.Get(), depending on the version ...
13 }
14 }
15}Unity has used incremental GC by default for several versions now (Project Settings > Player > Use incremental GC). It spreads collection over several frames and smooths out the spikes quite a bit. That doesn't make garbage free: the work still gets done, just in chunks. In a game that's already tight on its per-frame budget, like one with hundreds of projectiles, that spread-out work still takes its toll.
4. The Bullet Pool
The first pool was the bullet pool, since that's where the Profiler was pointing. Since Unity 2021 you don't need to write it by hand: the UnityEngine.Pool namespace ships ObjectPool<T>, a stack-based pool with callbacks for each moment of the lifecycle:
createFunc: how a new object is created when the pool is empty. This is whereInstantiategoes.actionOnGet: what happens when an object is taken out. UsuallySetActive(true).actionOnRelease: what happens when it's returned. UsuallySetActive(false).actionOnDestroy: what happens when the pool discards an object (because it's full or becauseClearis called). This is whereDestroygoes.collectionCheck: iftrue, throws an exception when returning an object that's already in the pool. It only checks in the editor.defaultCapacity: initial capacity of the internal stack. It doesn't create objects, it only reserves the space.maxSize: maximum number of inactive objects kept. If one is returned while the pool is full, it gets destroyed.
An ObjectPool<T> manages a single prefab, so with several bullet types the natural approach is one pool per prefab, accessible from a common place. That way the player, enemies, turrets and bosses all request bullets the same way, without every weapon having to set up its own pool.
1using System.Collections.Generic;
2using UnityEngine;
3using UnityEngine.Pool;
4
5public class ProjectilePools : MonoBehaviour
6{
7 [SerializeField] int defaultCapacity = 64;
8 [SerializeField] int maxPoolSize = 512;
9
10 readonly Dictionary<Bullet, ObjectPool<Bullet>> pools = new();
11
12 public Bullet Get(Bullet prefab)
13 {
14 if (!pools.TryGetValue(prefab, out var pool))
15 {
16 pool = CreatePool(prefab);
17 pools.Add(prefab, pool);
18 }
19 return pool.Get();
20 }
21
22 ObjectPool<Bullet> CreatePool(Bullet prefab)
23 {
24 ObjectPool<Bullet> pool = null;
25 pool = new ObjectPool<Bullet>(
26 createFunc: () =>
27 {
28 Bullet bullet = Instantiate(prefab, transform);
29 bullet.SetPool(pool);
30 return bullet;
31 },
32 actionOnGet: bullet => bullet.gameObject.SetActive(true),
33 actionOnRelease: bullet => bullet.gameObject.SetActive(false),
34 actionOnDestroy: bullet => Destroy(bullet.gameObject),
35 collectionCheck: true,
36 defaultCapacity: defaultCapacity,
37 maxSize: maxPoolSize);
38 return pool;
39 }
40}The change in the weapon code was minimal: Instantiate becomes pools.Get(prefab) and Destroy becomes pool.Release(this). The change in the bullet code was much bigger.
5. What Breaks When You Recycle
With Instantiate, every bullet is born clean: its values come from the prefab. With a pool, every bullet is born with whatever its previous life left behind. Adding the pool when the game already had many projectile types meant reviewing, one by one, every script that assumed the object was new. That's the expensive part of adding pooling late.
The typical symptoms of state coming back dirty are very recognizable:
- The bullet leaves with the velocity it had on impact, because nobody reset the
Rigidbody'slinearVelocity. - The
TrailRendererdraws a line from where the previous bullet died to the muzzle. The trail keeps its points even when the object is deactivated. - A bullet that received a modifier in its previous life (extra damage, piercing, bouncing from a player item) keeps it when fired from a weapon that doesn't have it.
- An event subscription added on launch and never removed: by the tenth reuse, the impact applies damage ten times.
Start and Awake only run once in the object's lifetime, and coroutines stop when the object is deactivated but don't resume when it's reactivated. So deactivating an object and activating it again won't call those methods.
A very useful rule to avoid these problems: everything that depends on the specific shot goes into an explicit reset method that's called when the object is taken out of the pool. None of it can live in Start.
The other classic bug is the double release. The bullet hits a wall in the same frame its lifetime expires, and both paths call Release. In the editor, collectionCheck throws an exception and you find out. In a build there's no check: the object goes into the stack twice, and the next two Get calls return the same bullet, which leads to strange behavior and bullets vanishing halfway. In a bullet hell, where collisions and lifetimes overlap constantly, this isn't a rare case. It can be solved with an "already released" flag on the object itself that prevents it from being released twice.
1using UnityEngine;
2using UnityEngine.Pool;
3
4[RequireComponent(typeof(Rigidbody))]
5public class Bullet : MonoBehaviour
6{
7 [SerializeField] float speed = 20f;
8 [SerializeField] float lifetime = 3f;
9
10 Rigidbody rb;
11 TrailRenderer trail;
12 IObjectPool<Bullet> pool;
13 BulletModifiers modifiers;
14 float timeLeft;
15 bool released;
16
17 void Awake()
18 {
19 rb = GetComponent<Rigidbody>();
20 trail = GetComponent<TrailRenderer>();
21 }
22
23 public void SetPool(IObjectPool<Bullet> owner) => pool = owner;
24
25 // All shot-dependent state is reset here, not in Start.
26 public void Launch(Vector3 position, Quaternion rotation, BulletModifiers mods)
27 {
28 transform.SetPositionAndRotation(position, rotation);
29 rb.position = position;
30 rb.rotation = rotation;
31 rb.linearVelocity = rotation * Vector3.forward * speed;
32 rb.angularVelocity = Vector3.zero;
33
34 if (trail != null)
35 trail.Clear(); // without this, a line from the previous death
36
37 modifiers = mods; // never inherit the ones from the previous life
38 timeLeft = lifetime;
39 released = false;
40 }
41
42 void Update()
43 {
44 timeLeft -= Time.deltaTime;
45 if (timeLeft <= 0f)
46 ReturnToPool();
47 }
48
49 void OnTriggerEnter(Collider other)
50 {
51 // ... apply damage based on modifiers ...
52 ReturnToPool();
53 }
54
55 void ReturnToPool()
56 {
57 if (released) return; // prevents double release in builds
58 released = true;
59 pool.Release(this);
60 }
61}A cheap way to hunt these bugs is to force reuse from the start. In development, with a small maxSize and lots of shooting, any state that isn't being reset shows up quickly.
6. Prewarming and Pool Size
A detail that confuses a lot of people is assuming that defaultCapacity preloads anything. The pool starts empty and the first shot still does an Instantiate. If the problem was the cost of creating objects mid-combat, a pool without prewarming just moves it to the first burst.
Prewarming means creating the objects during a load or a transition (when entering a level, for example) and returning them to the pool immediately. You have to take all the objects out first and then return them. If you alternate, the pool always hands back the same object and only one of each type gets created.
The opposite problem is a pool that never stops growing. Without a maxSize, or with the default value (10,000), a one-off spike leaves all those objects inactive forever. In our case, bosses were the natural spike. The practical approach is to instrument CountAll during the densest fights and set maxSize slightly above the maximum number of simultaneously active objects you observe. Anything beyond that gets destroyed when returned, which is exactly what you want for a rare spike.
1// In ProjectilePools, called when entering a planet or the boss room.
2public void Prewarm(Bullet prefab, int count)
3{
4 if (!pools.TryGetValue(prefab, out var pool))
5 {
6 pool = CreatePool(prefab);
7 pools.Add(prefab, pool);
8 }
9
10 // Take them all out first: alternating Get/Release only creates one.
11 var temp = new List<Bullet>(count);
12 for (int i = 0; i < count; i++)
13 temp.Add(pool.Get());
14
15 foreach (Bullet bullet in temp)
16 pool.Release(bullet);
17}Prewarming has a cost too: creating hundreds of objects at once causes a noticeable hitch. On a loading screen it doesn't matter; when entering the boss room it does. If you need to preload a lot, you can spread it across several frames with a coroutine. Or even always keep a loaded reserve for emergencies where preloading couldn't complete properly.
7. Beyond Bullets: Effects and Damage Areas
With bullets sorted out, the natural next step was the objects that came after them. Many player items in Otter's Hell don't just deal damage; they also leave damage areas on the ground, cause explosions on impact or spawn flashy particle effects that still have to be rendered. With an advanced build, every bullet could end up spawning two or three more objects, so the bullet problem repeated itself one level down.
Damage areas and explosions were handled the same way as bullets: one pool per prefab, an explicit reset when taken out (radius, damage, duration, who created them) and a return when finished. Particles have a handy feature: a ParticleSystem can notify you when it finishes if its stopAction is set to Callback, so the effect returns itself to the pool with no separate timers and no extra bookkeeping from the developer.
1using UnityEngine;
2using UnityEngine.Pool;
3
4[RequireComponent(typeof(ParticleSystem))]
5public class PooledEffect : MonoBehaviour
6{
7 ParticleSystem ps;
8 IObjectPool<PooledEffect> pool;
9
10 void Awake()
11 {
12 ps = GetComponent<ParticleSystem>();
13 var main = ps.main;
14 main.stopAction = ParticleSystemStopAction.Callback;
15 }
16
17 public void SetPool(IObjectPool<PooledEffect> owner) => pool = owner;
18
19 public void Play(Vector3 position, Vector3 normal)
20 {
21 transform.SetPositionAndRotation(position, Quaternion.LookRotation(normal));
22 ps.Clear(true);
23 ps.Play(true);
24 }
25
26 // Unity calls this when the system finishes (stopAction = Callback).
27 void OnParticleSystemStopped() => pool.Release(this);
28}If an effect moves with the object that spawned it (an aura, a trail following the bullet), you have to detach it from its parent when returning it to the pool. Otherwise, when the parent is recycled or deactivated, it drags along an effect that already belongs to something else.
8. The Pools We Removed
Here comes the most honest part of the post-mortem. Once we had the system set up and working for bullets, it was very easy to apply it to everything created during combat. And some of those pools, once measured, added nothing. We ended up removing them.
The pattern was always the same: effects or areas coming from rare items, appearing only a few times per room. The cost of creating them didn't show up in any profile, while the pool did bring things along: one more reset method to maintain, one more prefab to preload, memory held by inactive objects for the whole run, and one more source of dirty state bugs. With hundreds of different items in the game, every unnecessary pool was debt.
Keeping inactive objects isn't free. Every inactive GameObject takes up native and managed memory, stays in the hierarchy and counts toward scene searches. Activating and deactivating has its own cost: OnEnable and OnDisable run, and colliders enter and leave the physics scene. For objects reused only once in a long while, that cost can match the cost of instantiating them.
A pool isn't an optimization by itself. It's a trade: memory held and manual state in exchange for not paying for creation in the frame where you need it. If nobody was paying for that creation, the trade is a loss.
Not even for bullets in a bullet hell is it an automatic win. Mikko Saari tested this in his bachelor's thesis, Optimization for Bullet Hell Games (Savonia University of Applied Sciences, 2025). He built a test scene in Unity with rings of 200 bullets per second and compared three versions for ten minutes each: instantiate and destroy, a custom pool, and ECS. The pool came out worse than the unoptimized version: around 7,700 frames below 120 FPS versus around 5,800, and the GC hitches stayed exactly the same.
The author himself qualifies the result, and those caveats are the most useful part of the study. His pool had dirty state bugs he never fixed: with Rigidbody, recycled bullets didn't reset their position and the patterns came out distorted. He only measured in the editor, not in a build. And since the GC didn't change after adding the pool, the garbage was coming from somewhere else. In other words, the pool wasn't attacking the real problem, and it was adding bugs on top. What ended up solving his performance wasn't recycling better, but no longer having one GameObject per bullet: with ECS he reached around 540 FPS on average.
The criterion we ended up with for deciding whether something deserves a pool has three questions: is it created many times per second, or in bursts? Is it short-lived? Does it show up in the Profiler? If all three answers are yes, pool it. If any is no, Instantiate and move on. And for garbage that isn't scene objects (temporary lists for finding targets, for example), UnityEngine.Pool also ships ListPool<T>, HashSetPool<T> and GenericPool<T>, which solve the problem without touching the hierarchy.
9. A Good Candidate: Sparkles' Footprints

If I had to pick one well-justified example of a pool that isn't a bullet, it would be the decals for Sparkles' footprints on the ground. It answers all three questions without debate: they're created continuously while the player moves (and in a bullet hell the player never stops moving), each one lives a few seconds before fading, and without a pool they're an Instantiate and a Destroy every few steps for the whole run.
They also have a property that simplifies the pool a lot: the number of footprints visible at once is bounded. If each footprint lasts a few seconds and the player takes a few steps per second, there's never more than a fixed number on screen. That lets you swap the ObjectPool<T> stack for something even simpler, a ring buffer: a fixed-size array created up front, where each new footprint reuses the oldest one.
1using UnityEngine;
2
3public class FootprintTrail : MonoBehaviour
4{
5 [SerializeField] Footprint footprintPrefab;
6 [SerializeField] int maxFootprints = 32;
7
8 Footprint[] footprints;
9 int next;
10
11 void Awake()
12 {
13 footprints = new Footprint[maxFootprints];
14 for (int i = 0; i < maxFootprints; i++)
15 {
16 footprints[i] = Instantiate(footprintPrefab);
17 footprints[i].gameObject.SetActive(false);
18 }
19 }
20
21 // Called from an animation event on every step.
22 public void Step(Vector3 position, Quaternion rotation)
23 {
24 Footprint footprint = footprints[next];
25 footprint.Place(position, rotation); // resets the fade and activates it
26 next = (next + 1) % maxFootprints;
27 }
28}There's no Release, no possible double release and no growth: if the player runs faster than expected, the oldest footprint disappears a bit earlier, which nobody notices visually. It's a good reminder that "pool" doesn't have to mean ObjectPool<T>. When the maximum is known and reuse order doesn't matter, a ring buffer is simpler and cheaper.
10. What About Enemies?
Pooling enemies is the question that always comes up, and we asked ourselves too. It's not as clear-cut a decision as bullets, so it's worth laying out the pros and cons.

Pros:
- Enemy prefabs are heavy.
Animator, AI, colliders, children with effects. If instantiating a bullet is cheap, instantiating an enemy can be noticeable, especially when several appear at once on entering a room. - There are waves. In rooms with waves or spawners, enemies are created and destroyed in bursts, which is exactly where a pool shines.
- Prewarming fits well. The enemy composition of each room is known when it's generated, so you could preload exactly what's going to be needed.
Cons:
- Far more state to reset. Health, AI state, current target, applied status effects, ongoing animation, subscriptions to room events, assigned loot. Every forgotten field is an enemy that respawns half dead, on fire, or chasing a target that no longer exists.
- They live much longer. An enemy lasts seconds or minutes, not milliseconds. Reusing it saves far fewer creations per second than reusing bullets.
- Lots of variety. One pool per enemy type, in a roguelite with several planets and many types, means many pools full of inactive objects that might never be used again during the run.
My conclusion is that the cost of spawning enemies is better tackled in other ways first (spreading spawns across several frames, slimming down prefabs, preloading assets rather than objects) and that a pool only pays off if the Profiler shows that enemy Instantiate is the problem. Interestingly, Unity reached the same split in its own multiplayer sample, as the next section shows.
11. Other Games and Engines That Do It
Few studios publicly document how they handle their projectiles, but there are clear examples that the split we made (pool for what's created en masse, Instantiate for the rest) is the usual one:
- Boss Room, Unity's multiplayer sample. It uses a
NetworkObjectPoolfor projectiles. The code comments note that imps (the basic enemies) could use it too, but they're deliberately left with normal spawning so the two approaches can be compared. It's exactly the debate from the previous section, settled the same way. Netcode documentation on object pooling. - Niagara in Unreal. Epic considers effects such a clear case for pooling that it built it into the engine:
SpawnSystemAtLocationaccepts anENCPoolMethodand the per-world pool manages itself. For actors, on the other hand, there's no official pool, which says a lot about where they see the benefit. - Bullet hell tools for Unity. Assets like Uni Bullet Hell include their own built-in bullet pool (
UbhObjectPool) and require you to return projectiles to it instead of destroying them. In the genre, a bullet pool is taken for granted. Uni Bullet Hell. - Jam games in the genre. The post-mortem of Sneeze Hell, a bullet hell made in Unity for a jam, credits its browser performance to bullet pooling together with the Job System and Burst. Sneeze Hell post-mortem.
- ECS as an alternative. At the other extreme, Mikko Saari's study cited in section 8 ended up dropping the pool and moving bullets, spawners and pickups to ECS, leaving the rest of the game in
GameObjects. When the number of projectiles is very high, the question stops being how to recycle objects and becomes whether bullets need to be objects at all. - Game Programming Patterns. The Object Pool chapter of Robert Nystrom's book uses a particle system as its example, and spends a good part of the text on the same things that cost us: what to do when the pool fills up and how to keep a recycled object from dragging state along.
12. Conclusions
If I had to build this system again from scratch, I'd do it in this order:
- Bullet pool from the start in a bullet hell. It's the only case where you don't need to measure to know the answer. Adding it late forced us to review every projectile that assumed it was born clean, and that cost far more than doing it right from the first prototype.
- Everything else, only with data. Effects, areas, explosions: pool them if they're created en masse, short-lived and visible in the Profiler. Otherwise,
Instantiate. - Use what the engine provides.
ObjectPool<T>in Unity, the Niagara pool in Unreal. And a ring buffer when the maximum is known, as with the footprints. - Reset everything in one place. A method that leaves the object just as if it came fresh from the prefab, and a flag against double release.
- Prewarm during transitions and cap with
maxSize. The size comes from measuring the densest fights, not from a round number. - Remove pools that aren't justified. A pool that fixes nothing isn't neutral: it's manual state, held memory and bugs waiting to happen.
In a bullet hell, the bullet pool is an architecture decision, not an optimization. Everything else is an optimization, and like any optimization, you measure before you do it.

