Quick answer: GameMaker persistent room keeping every instance ever created? The persistent flag preserves all instances across re-entry — unmanaged spawns pile up indefinitely.
A hub world is set persistent so the player returns to the same state. Each visit adds NPCs created on entry; over time hundreds accumulate.
Spawn Once, Persist
For persistent rooms, spawn entities in Room Start only if they don’t exist. Track a creation flag — if (!instance_exists(obj_NPC)) instance_create_layer(...).
Cleanup on Exit
Use Room End event to destroy non-essential instances. Keeps persistence to the meaningful state (player position, quest flags) not to literal instances.
Non-Persistent Room with State
Save state to globals or a manager on Room End; restore in Room Start. Decouples instance lifecycle from state persistence — cleaner architecture.
Memory Profile
Track instance count and memory across multiple visits to the persistent room. Growth indicates leak; flat = clean.
Verifying
Multiple visits to the persistent room don’t accumulate instances. Player position and important state restored cleanly.
“Persistent rooms preserve all instances. Manage spawn/destroy explicitly.”
Reserve persistent rooms for hub worlds. Gameplay rooms should serialize state to globals on exit — cleaner, easier to debug.