Skip to catalogue

92

object pool

Reuse bullets and particles. Allocating every shot is how the frame hitch arrives.

What is object pool?

An object pool preallocates N objects and hands out inactive ones. Release returns them. The point is stable memory and no garbage spikes, not “elegance.”

Why does object pool matter when vibe coding?

Models `spawn = new Bullet()` in the fire handler. At a high fire rate the garbage collector stutters the frame. Name the pool and the cap.

How do you do object pool?

Pool anything spawned many times a second: bullets, particles, damage numbers. Fixed cap. If the pool is empty, refuse or recycle the oldest. Do not grow without a limit.

How do you ask a model for object pool?

Pool (objects). Preallocate (N). Take an inactive one on spawn, release on death. If none are free, recycle the oldest or drop the spawn. Do not allocate per shot.

What goes wrong with object pool?

A pool that still allocates when empty “just this once.” That once is the hitch you were avoiding.

adjacent