VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/object-pooling-in-unity/

⇱ Object Pooling In Unity - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Object Pooling In Unity

Last Updated : 4 May, 2026

Object pooling is a performance optimization technique. Instead of destroying an object, you deactivate it and add it back to a pool. When needed again, you reuse it instead of creating a new one.

  • No repeated Instantiate() and Destroy() calls
  • Reduces garbage collection and lag spikes
  • Essential for mobile games and bullet-hell shooters

Problem without Pooling

When you instantiate and destroy objects frequently, Unity keeps allocating and freeing memory. This causes lag spikes.

Every time you destroy an object, Unity's garbage collector has to clean it up later, causing frame drops.

With Pooling

Create a pool of objects at start. Reuse them instead of destroying.

Using the Object Pool

Here's how to shoot using the object pool.

Generic Object Pool (Reusable)

Create one pool that works for any type of object.

Usage:

When to Use Object Pooling

Good for

  • Bullets in shooting games.
  • Enemies that spawn frequently.
  • Particle effects (explosions, dust).
  • Pickups (coins, health items).

Not needed for

  • UI elements.
  • Bosses (spawn rarely).
  • Scene objects.
  • Static environment.

Without Pooling vs With Pooling

FeatureWithout PoolingWith Pooling
Object HandlingUses Instantiate() and Destroy() repeatedlyReuses objects (activate/deactivate)
Performance ImpactCauses garbage collection → lag spikesAvoids garbage collection overhead
SpeedSlowerMuch faster
ImplementationSimple to implementRequires extra setup/code
Comment
Article Tags:
Article Tags:

Explore