Skip to content
RED SAGSkills
mediumGame Developer interview question

Describe how you would design a reusable object pool and what trade-offs it has.

What the interviewer wants to hear

  • Pre-create objects and reuse them instead of Instantiate and Destroy
  • Reset state on get and release, with OnSpawn and OnDespawn hooks
  • Decide growth policy: fixed size, grow, or recycle oldest
  • Trade memory for fewer allocations and hitches
  • Bugs from stale state or references to returned objects; Unity ObjectPool API

Model answer

An object pool keeps a set of inactive objects and hands them out instead of creating new ones, then takes them back instead of destroying them. That avoids allocation and garbage collection spikes, and Instantiate costs. I would build a generic pool, or use Unity's ObjectPool<T>, with create, get, release and destroy callbacks. On get, the object resets its state, like health, velocity and particle systems, and on release it is deactivated. I prewarm the pool during loading to the expected peak, and decide the growth policy: grow with a warning, or recycle the oldest, which suits bullet holes. The trade-offs are memory held all the time, and bugs from objects that keep stale state or from code that still holds a reference after releasing. Debug checks for double release help.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Game Developer questions