bevyengine / bevyengine/bevy

Unreasonable RAM/Memory usage

Open
#21,465 6 comments 3 reactions 0 assignees View on GitHub
A-Cross-Cutting A-Rendering C-Performance S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version and features

v0.16.x and v0.17.x; default features

## Relevant system information

Linux Mint 64-bit; either X11 or Wayland

## What you did

Make the simplest bevy app possible, and measure RAM usage.

```rust
// main.rs
use bevy::prelude::*;

fn main() {
let mut app = App::new();
app
.add_plugins(DefaultPlugins)
.run();
}
```

## What went wrong

Just loading default plugins results in 590MiB of memory being consumed with bevy v0.17.2 on my machine.

## Additional information

I noticed on bevy v0.16.x that my very simple 2d app with one sprite, a handful of entities, and a few sounds consumed ~400MiB of RAM. This seemed extreme to me at the time. I tried to remove unnecessary bevy features, but only managed to save a few MiB. I decided to figure it out later.

Today I upgraded to bevy v0.17.2, and memory usage has ballooned to 590MiB! To rule out my code and other plugins, I made a new project that just loads the default plugins. The results where the same ~590MiB of memory consumption.

I made a couple of variants with different plugins. The biggest difference I found was when I enabled `RenderPlugin`, with an increase of just over 400MiB.

Using v0.17.2
* `MinimalPlugins`: ~27MiB
* custom plugins w/o `RenderPlugin`: ~58MiB
* custom plugins with `RenderPlugin`: ~466 MiB
* `DefaultPlugins`: ~590MiB

Contributor guide

Open the contributing guide

Research direction

Start with the minimal main.rs example and reproduce the reported memory usage on Linux using Bevy 0.17.2. Compare MinimalPlugins and custom configurations with and without RenderPlugin, then profile the memory increase. Done means the source of the RenderPlugin-related usage is identified and the issue is fixed or its expected behavior is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
44/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.