Object pooling implementation for mobile game

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Object pooling implementation for mobile game
Medium
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Object Pooling for Mobile Games

Every time a bullet, coin, or explosion particle spawns in a game, Unity calls Instantiate, and on destroy—Destroy. Unnoticed on desktop. On mobile GPU with 4 GB shared memory and a Garbage Collector running in the same thread as render, this manifests as a characteristic 30–80 ms freeze when enemies spawn or explosion with particles trigger.

Where It Breaks Without Pooling

The problem isn't memory allocation itself—it's that GC in Mono (which Unity mobile still often uses) stops the world for collection. Instantiate creates managed objects eventually collected. On frequent spawn/destroy, collection triggers at the heaviest moments—explosions, many on-screen enemies, level transitions.

Typical symptoms: Profiler shows periodic GC.Collect spikes of 40–120 ms on Galaxy A53 or iPhone 12 devices. Flagships have smaller spikes, but on target devices with Android 10–12 and 3–4 GB RAM they're consistent.

Second aspect—memory fragmentation. Frequent allocation and freeing leaves many small "holes" in the heap. On next large allocation, the system requests a new block from OS. On Android this sometimes triggers LMK (Low Memory Killer) sooner than expected.

How We Implement Pooling

Basic pattern—ObjectPool<T> with two stacks: active and inactive. On object request, take from inactive, activate (SetActive(true)), add to active. On return—opposite. No Instantiate in hot path.

Starting Unity 2021, there's built-in UnityEngine.Pool.ObjectPool<T>, eliminating reinvention. Thread-safe via ConcurrentStack under hood, supports actionOnGet / actionOnRelease / actionOnDestroy callbacks. Write thin wrapper for each pool type—bullets, enemies, particles—with explicit maxSize to prevent unbounded growth.

var pool = new ObjectPool<Bullet>(
    createFunc: () => Instantiate(bulletPrefab),
    actionOnGet: b => b.gameObject.SetActive(true),
    actionOnRelease: b => b.gameObject.SetActive(false),
    actionOnDestroy: b => Destroy(b.gameObject),
    maxSize: 100
);

For particles (ParticleSystem)—special logic. Return particle to pool not by timer, but on OnParticleSystemStopped event. Otherwise return happens while particles still fly, effect cuts off visually.

Pool Warm-up

A pool is useless if it fills during gameplay. Warm up on loading screen: create needed quantity, immediately return to pool. This moves allocations where user doesn't notice.

Count—not "with headroom", but based on analysis of max simultaneous objects on heaviest level. If 60 bullets peak on screen—warm up 80.

Pools with Addressables

If project uses Addressables, pooling gets complex: Instantiate works via Addressables.InstantiateAsync, result is AsyncOperationHandle. On return to pool, can't just call Destroy—must Addressables.ReleaseInstance. Write pool manager accounting this, or get native memory leak in IL2CPP build.

Profiling Before and After

Before pooling: Profiler shows GC.Alloc 2–8 KB per bullet spawn + periodic GC.Collect 50+ ms. After: hot path has zero allocations, GC.Collect fires only on level transitions.

On Pixel 6a with 20 simultaneous enemies and active pool—stable 60 FPS vs 45–55 without pool.

Process

Audit existing code → identify hot paths with Instantiate/Destroy → implement pools with warm-up → integrate into SpawnManager → profile in Editor Profiler and on device via Android GPU Inspector or Xcode Instruments. Testing on low-end device (Galaxy A32 level) mandatory—difference is most noticeable there.

Timeline: two-five workdays depending on object types and existing architecture.