bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.08k stars 3.56k forks source link

Memory Profiling Support #6927

Open james7132 opened 1 year ago

james7132 commented 1 year ago

What problem does this solve or what need does it fill?

The 3d_scene example currently uses 107.5 MB of resident memory on my machine, even with all of the optimizations enabled. For a simple rendered scene of a box and a plane, I'd expect that to be lower. To better address this, it's important to be able to profile and monitor the memory behavior of Bevy apps.

What solution would you like?

Either better docs or tooling for the following:

For best platform support, this ideally should also support doing this remotely, though this might be dependent on platform specific tooling.

What alternative(s) have you considered?

Blindly start shrinking data structures and cutting dependencies until memory usage goes down.

hymm commented 1 year ago

I was able to use https://crates.io/crates/leak-detect-allocator to find the memory leak fixed in https://github.com/bevyengine/bevy/pull/6878. It shows all the stuff that was allocated without a matching deallocation. But a lot of allocations don't show up since some things are allocated and deallocated during a single frame. Bevy does runs at like 0.1 FPS when using it though, so might not be suitable for a lot of applications.

hymm commented 1 year ago

ran into https://crates.io/crates/dhat and https://github.com/koute/bytehound. That might be worth looking at.