-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
MeshAllocator leaks GPU memory on in-place mesh modification #24892
Copy link
Copy link
Closed
Labels
A-AssetsLoad files from disk to use for things like images, models, and soundsLoad files from disk to use for things like images, models, and soundsA-RenderingDrawing game state to the screenDrawing game state to the screenC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorC-PerformanceA change motivated by improving speed, memory usage or compile timesA change motivated by improving speed, memory usage or compile timesD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesP-HighThis is particularly urgent, and deserves immediate attentionThis is particularly urgent, and deserves immediate attentionS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Milestone
Description
Metadata
Metadata
Assignees
Labels
A-AssetsLoad files from disk to use for things like images, models, and soundsLoad files from disk to use for things like images, models, and soundsA-RenderingDrawing game state to the screenDrawing game state to the screenC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorC-PerformanceA change motivated by improving speed, memory usage or compile timesA change motivated by improving speed, memory usage or compile timesD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesP-HighThis is particularly urgent, and deserves immediate attentionThis is particularly urgent, and deserves immediate attentionS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Bevy version and features
0.19.0, default features.
Relevant system information
What you did
Repeatedly modified existing
Meshassets in place (destructible voxel bodies re-meshed on every hit). Reduced to: spawn entities each with their ownMesh3d, then each frame mutate every mesh in place, reassigning identical data is enough to trigger it:What went wrong
Expected: re-uploading a modified mesh frees/reuses its previous GPU allocation, so steady-state memory is bounded.
Actual:
get_mut(raisingAssetEvent::Modified) never frees the mesh's previous allocation inMeshAllocator's general slabs, so every modification leaks the old buffer. Process commit/VRAM grows without bound while the CPU-sideAssets<Mesh>count and all ECS state stay flat. With ~32 meshes re-uploaded/frame, commit climbs ~27 MB/s indefinitely (1.1 -> 2.2 GB in 42 s).