godotengine / godotengine/godot

Running out of VRAM will cause huge stutters until the game is restarted

Open
#95,254 16 comments 1 reaction 0 assignees View on GitHub
discussion performance topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: v4.2.stable.mono.official [46dc27791], v4.3.rc2.mono.official [3978628c6]

### System information

Godot v4.3.rc2.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970M (NVIDIA; 32.0.15.5599) - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (8 Threads)

### Issue description

When the GPU VRAM is full or almost full, the game will experience very long and reccurent stutters, which can only be fixed by closing the project, freeing up VRAM (either by closing other programs like Discord, or reducing texture and/or reflection probe resolution), and starting the project up again.

These stutters last for several seconds and happen every second or so of fluid gameplay. Also, the only happen when the game is running, not in the editor.

While this is not an issue in 2D games and light 3D games, it can be a big problem for people with would want to play a more demanding game on a computer with not much VRAM, which would otherwise run fine without that VRAM hurdle, especially with solutions like FSR 2.

This is even more a problem with the fact that Godot 4 does not have a way to reduce texture resolution at runtime or texture streaming, which harms scalability a lot for bigger games.

The MRP provided in this form takes approximately 4 GB of video memory and displays everything correctly on screen (no VRAM artifacts, no visual corruption or anything like this), aside from the huge stutters. Furthermore, the RAM usage ramps up quickly once the VRAM is saturated, which leads me to believe video data is loaded to the RAM as it should, once the GPU runs out of VRAM.

I would believe the issue lies in the way said data is being read from the RAM, which may be the cause for such a big overhead. (Please note that I am no graphics programmer, this is just a somewhat "educated" guess).

_Note : the MRP has an absurd amount of high-resolution reflection probes which is something you would never have to do in 99,9 % of game projects, the goal was to stress-test the VRAM to show the issue. It also happens in a normal case scenario, like a game with several 2k textures and a couple reflection probes._

### Steps to reproduce

1. Create a new project (or open an existing one)
2. Add resources and nodes that will use VRAM (Texture2D/3D, reflection probes, and so on)
3. Play the project. If you experience no stutters, monitor VRAM usage with the profiler, and repeat step 2 until you run out of VRAM
4. You should now notice the stutters happening when the game is running.

### Minimal reproduction project (MRP)

[VRAM MRP.zip](https://github.com/user-attachments/files/16531083/VRAM.MRP.zip)

Contributor guide

Open the contributing guide

Research direction

Download the linked VRAM MRP and reproduce the issue in Godot v4.3.rc2 while monitoring VRAM and RAM usage. Compare runtime behavior with the editor and test whether recurring multi-second stutters remain after VRAM saturation; done means the project no longer requires a restart to recover smooth gameplay.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, game-dev, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.