skip to content

In an open world that streams cells around the player, why do cells near a border load and unload repeatedly, and how do you design streaming decisions to stop it?

level: seniorimportance: should knowfreq 45%

answer

  1. one threshold, two directions
  2. load radius smaller than unload radius
  3. speed times worst-case latency
  4. spread activation over frames

basics

~20 s

A single distance threshold flips a cell's state every time the player crosses it. Use hysteresis — load inside a smaller radius, unload only beyond a larger one — plus velocity-based prediction, a minimum residency time and a per-frame activation budget.

solid answer

~50 s

With one radius, a player wandering along a border crosses it again and again, and each crossing requests a load or an unload, so the same cell is read, activated and torn down repeatedly — wasted I/O, hitches and memory churn. **Hysteresis** separates the thresholds: request a load inside `r_load` and an unload only beyond a larger `r_unload`, so the player must travel the whole band before the state can flip again; a minimum residency time adds a second guard. Prioritise requests by distance and by the player's predicted position, and size `r_load` so content arrives in time: it must exceed the distance at which a cell must be ready by at least top speed times worst-case load latency. Cells load **additively** into a persistent world, and their objects are activated and deactivated across several frames under a time budget. State such as an opened door is saved by stable ID when a cell unloads and reapplied on reload.

code

pseudocode · 8 lines
pseudocode
for cell in candidateCells:
    d = distance(predictedPlayerPosition, cell.center)
    if cell.state == UNLOADED and d < R_LOAD:
        requestLoad(cell, priority = d)
    else if cell.state == RESIDENT and d > R_UNLOAD
            and now - cell.residentSince >= MIN_RESIDENCY:
        requestUnload(cell)
    // between R_LOAD and R_UNLOAD the cell keeps its current state

go deeper

for a junior

Recall that open worlds keep only nearby cells in memory and load others as the player approaches.

for a middle

Explain why one distance threshold causes repeated loads and unloads, and how separate load and unload radii stop it.

for a senior

Size the radii from top speed, worst-case latency and the memory budget, prioritise by predicted position, time-slice activation, and persist changed cell state by stable ID.

for a principal

Treat traversal speed, resident memory and pop-in as one budget negotiated with design, including what happens on fast travel and on servers hosting many players.

## Streaming decisions vs the loading beneath them An open world too large for memory is split into **cells** — regions of the map, often squares on a grid — and only the cells near the player are kept **resident**. Two layers cooperate. The **decision layer**, the subject here, chooses which cells should be resident, in what priority, and when to activate or release their objects. The **loading layer** beneath it reads cooked data asynchronously and hands it over; how that data is cooked, laid out and read is covered with the asset pipeline. Most streaming bugs that players notice — pop-in, repeated hitches near certain places, memory spikes — are decision-layer bugs. ## Why a single threshold thrashes The naive rule is "a cell is resident while its distance to the player is below `r`". Its flaw is that the rule is symmetric. A player walking along a road that runs near the threshold, circling a camp, or stepping back and forth through a doorway crosses `r` many times a minute. Every crossing outward requests an unload and every crossing inward requests a load, so the same cell is: - read again, competing with cells the player actually needs; - activated again, creating its objects and registering them in spatial structures; - torn down again, freeing memory that is reallocated seconds later. The symptom is a hitch that repeats at one spot and an I/O queue that never drains. A faster disk shortens each cycle but does not stop the cycling. ## Hysteresis and residency **Hysteresis** gives the two directions different thresholds: 1. request a **load** when the distance drops below `r_load`; 2. request an **unload** only when the distance rises above `r_unload`, with `r_unload > r_load`; 3. optionally require a **minimum residency time** before any unload. Between the two radii the cell keeps whatever state it has. With an illustrative `r_load` of 300 m and `r_unload` of 400 m, a player oscillating between 290 m and 360 m from a cell loads it once and keeps it. For the cell to unload and then load again, the player must cross the whole 100 m band outward and come back. The band costs memory: the resident set is roughly all cells within `r_unload`. With 100 m cells and a 400 m unload radius that is about `3.14 * 400^2 / 100^2`, roughly 50 cells, so the band width is a memory-budget decision, not a free parameter. ## Priority and prediction Loading takes time, so the decision layer must ask early enough: - **Lead distance.** If the fastest vehicle travels at 40 m/s and a cell's worst-case streaming latency is 3 s, the player covers 120 m before the cell is ready, so `r_load` must exceed the distance at which that cell's content has to be ready by at least 120 m. Faster traversal grows the needed radius, and the resident area grows roughly with its square. - **Priority.** Order pending requests by distance and, better, by distance to the player's **predicted** position along their velocity, so cells ahead of a speeding vehicle outrank cells behind it. - **Cancellation.** A request for a cell the player has turned away from should be cancelled or demoted rather than finished. - **Fallbacks.** When prediction fails, a coarse always-loaded representation or a gate in level design (a narrow canyon, a slow door) buys time. ## Additive loading and activation budgets Cells load **additively**: they are added to a persistent world that always holds the player, game state and global systems, rather than replacing a level. Once a cell's data is in memory it still has to be **activated** — objects created, attached to the transform hierarchy, registered in spatial query structures, initialised by gameplay — and that work runs on the main thread in many engines. A dense cell activated in one frame blows the frame budget even though its I/O finished long ago. The remedies: - activate objects across several frames under a fixed time slice; - deactivate and release unloading cells incrementally too; - keep the number of cell transitions per frame bounded. ## State that must survive unloading Unloading a cell discards its live objects, but the world must remember what the player changed: a looted chest, a killed boss, an opened gate. Each such object needs a **stable ID**; on unload its changed state is written to a world-state store, and on reload it is reapplied after the authored data is activated. Missing this produces respawning enemies and refilled chests. ## Dedicated servers A server streams around **every** player: the resident set is the union of all players' interest areas, and hysteresis matters even more because many players cross borders. Servers usually load only gameplay data — collision, spawn points, scripts — without render data, so their cells are lighter but their resident set is wider.

  • The game adds fast travel to any map location. How should streaming handle it?
    No radius can cover an instant jump, so fast travel is treated as a discrete transition: show a loading screen or transition effect, request the destination's cells at top priority, unload what is no longer needed, and release control only when the cells around the arrival point are resident and activated.
  • Why can a streamed cell cause a hitch even though its data was read asynchronously?
    Reading the data is only half the work. Creating its objects, attaching them to the hierarchy, registering them in spatial structures and running their initialisation usually happens on the main thread, and a dense cell done in one frame overruns the budget. Time-slicing activation across frames, and doing the same for teardown, removes the spike.
  • How does streaming differ on a dedicated server hosting many players?
    The resident set is the union of every player's interest area rather than one circle, so memory scales with how spread out players are. Servers typically load only gameplay data such as collision, spawn points and scripts, skip render data, and need hysteresis even more because many players cross cell borders all the time.

  • Unload a cell the moment the player leaves its load radius to save memory.
  • Streaming thrash is a disk speed problem; faster storage fixes it.
  • Once a cell's data is in memory, activating all its objects in one frame is fine.
  • Unloading can discard a cell completely; reloading restores it as authored.
  • The load radius only needs to match the draw distance.