Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
TroubleshootingNovember 22, 20265 min read

Game slows down the longer you play

A game that gets slower every minute is collecting something it never throws away. Count it, find it, and clean it up.

Startbase Team
Editorial ink illustration of an hourglass with its lower bulb overflowing with bottle caps and spent shells, the hourglass neck in ember orange

Key takeaways

  • Gradual slowdown means something accumulates: objects never removed, listeners added on every restart, textures never freed, or timers that stack.
  • Count things over time (live entities, scene children, listeners, memory) and the one that only goes up is the leak.
  • Restarting a level is the classic trigger: if the third run is slower than the first, cleanup is missing.
  • Phones also slow down from heat after several minutes; tell that apart from a leak by restarting the game without reloading.

A game that runs smoothly at first and slows down the longer you play is almost always leaking: something is created over and over and never removed. The usual suspects are bullets, particles or enemies that leave the screen but stay in the update list, event listeners added again each time a level restarts, textures and 3D geometry that are never disposed, and timers or intervals that stack up. Each one adds a tiny cost every frame until the frame budget runs out. Find the count that only goes up, and clean it up when its owner dies.

Leak, heat or garbage collection?

Three different problems feel like "it gets slower". Separate them before you change code.

  • A leak: slowdown grows steadily, gets worse with each level restart, and goes away completely when you reload the page.
  • Thermal throttling: on phones, the chip slows down after roughly 5 to 10 minutes of heavy load to cool off. The phone feels warm, and the game stays slow after a restart without a reload, but recovers after the phone rests. The fix is doing less per frame overall, covered in game performance on phones.
  • Garbage collection hitches: not slower overall, but regular freezes of a tenth of a second or so as the browser cleans up short-lived objects. Pools and reused arrays fix this.

Quick test: play for 5 minutes, restart the level from the menu (no page reload) and compare the first 10 seconds with a fresh page load. Slower after restart means a leak.

Causes, most likely first

1. Objects that leave the screen but never die

Bullets fly off the edge, particles fade to invisible, enemies fall off the map, and they all keep running their update every frame and stay in the scene. After 5 minutes of a shooter you can have tens of thousands of invisible objects. Check: show a debug counter with the length of each entity list and the number of children in the scene or stage. If it climbs and never falls, you found it. Fix: remove objects when they leave the play area, finish their animation or lose all health, from both the update list and the display tree. Better, use an object pool: create 200 bullets once and recycle them.

2. Listeners and loops added on every restart

The level setup adds a keydown listener, a resize handler, a pointer handler and starts an animation loop. Restart runs setup again without removing the old ones. After five restarts, every key press is handled five times and five loops update the game each frame. A telltale sign: the player moves faster after each restart, or a sound plays several times. Fix: every setup has a matching teardown that removes listeners, cancels the animation frame and clears intervals. Use one game loop for the whole session and switch scenes inside it.

3. Textures, geometry and materials never disposed

In Three.js, removing a mesh from the scene does not free its GPU memory; geometry, materials and textures need dispose() calls. In PixiJS, textures created at runtime (from text, render textures or generated images) also need destroying. Text objects that change every frame (a score drawn as a new texture each update) are a classic slow leak. Check: in the browser's performance monitor, watch JS heap and, in 3D, the renderer info counts for geometries and textures; they should level off, not climb. Fix: dispose what you remove, reuse materials, and update existing text objects only when the value changes.

4. Arrays and histories that only grow

A trail effect that stores every past position, a replay log, a list of "recent hits" for combo logic, or analytics events queued but never sent. Each costs memory and, if the game loops over it every frame, time. Fix: cap every history (keep the last 100 positions, not all of them) and loop only over what is needed.

5. Timers that stack

setInterval inside a function that runs on every wave, or setTimeout chains started by each enemy, keep running after the wave ends. Fix: track timers by owner and clear them in teardown, or drive spawns from the game loop with elapsed time instead of browser timers, which also keeps them correct while paused.

6. Difficulty that scales without limit

Not a bug, but it looks like one: spawn rates or enemy counts that grow forever. At minute 12 there are 400 enemies on screen. Fix: cap simultaneous enemies (for example 60 to 120 on phones, depending on how heavy each is) and raise challenge with speed, patterns or tougher enemy types instead. Enemy waves and spawners shows how.

7. A new audio object for every sound

Creating a fresh audio element or audio buffer each time a coin is collected or a shot is fired adds up fast in an action game: hundreds of sounds a minute, each holding memory until the browser gets around to freeing it, and on some phones a cap on simultaneous audio that makes later sounds fail. Fix: decode each sound file once at load, play it from that shared buffer, limit how many copies of one sound can overlap (four is plenty for a gunshot), and stop looping sounds when their owner dies.

A 10-minute measurement

  1. 01Ask for a small debug overlay: frames per second, frame time, entity count per type, scene children, active listeners, and on desktop Chrome the JS heap size.
  2. 02Play for two minutes, note the numbers. Play two more, note again. Restart the level twice, note again.
  3. 03Anything that rises steadily across all three readings is the leak. Frame time rising with entity count confirms it.
  4. 04Fix, then repeat the same run. Counts should go up and down with gameplay and return to a baseline after a restart.

The message to send the agent

The game is smooth for the first minute but drops to about 25 fps after 5 minutes, and gets worse after each restart. Add a debug overlay (toggle with the D key) showing fps, frame time, counts of bullets, enemies, particles, scene children and active event listeners. Then make sure bullets and particles are removed or returned to a pool when they leave the screen or finish, every level setup has a teardown that removes listeners, timers and the animation loop, removed meshes dispose their geometry, materials and textures, and the score text only updates when the score changes. Cap enemies on screen at 80. Do not change gameplay.

Run the measurement again after the fix. If you want to compare against a build from before the slowdown appeared, preview earlier versions from Versions; restoring saves your current work as a version first, so you can always return (versions docs). Startbase games run on PixiJS for 2D and Three.js for 3D, so the dispose advice above applies directly (games template).

Frequently asked questions

Why does my game get slower every time I restart a level?

Restart is running setup again without cleaning up the previous run, so listeners, loops, timers or objects pile up. Pair every setup step with a teardown.

Is it a memory leak or just my phone getting hot?

Restart the level without reloading the page. If it is fast again after a page reload but not after a restart, it is a leak. If it stays slow until the phone cools down, it is thermal throttling.

Does removing an object from a Three.js scene free its memory?

No. Call dispose() on its geometry, materials and textures when you no longer need them, or reuse them for new objects.

What is object pooling?

Creating a fixed set of objects, such as bullets, once and recycling them instead of creating and deleting new ones. It avoids leaks and garbage collection pauses.

On this page

  • Leak, heat or garbage collection?
  • Causes, most likely first
  • A 10-minute measurement
  • The message to send the agent

Keep reading

More in Troubleshooting
Editorial ink illustration of an overstuffed card catalog drawer spilling index cards, the brass tab of one card in ember orange
TroubleshootingNovember 22, 2026

Why is my app slow with lots of data?

An app that slows down as data grows almost always loads or draws too much at once. Here is how to find which part is slow and the fix for each.

6 min read
Editorial ink illustration of a border checkpoint with a lowered barrier arm and a waiting parcel, the guard's stamp in ember orange
TroubleshootingNovember 22, 2026

CORS errors explained and fixed

A CORS error means the server you called did not say your website is allowed to read its answer. The fix lives on that server, or in a server function you control.

5 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.