bevy/crates/bevy_render
Brian Reavis 680c994100
Fix TextureCache memory leak and add is_empty() method (#14480)
# Objective

Fix a memory leak in `TextureCache` caused by the internal HashMap never
having unused entries cleared.

This isn't a giant memory leak, given the unused entries are simply
empty vectors. Though, if someone goes and resizes a window a bunch, it
can lead to hundreds/thousands of TextureDescriptor keys adding up in
the hashmap – which isn't ideal.

## Solution

- Only retain hashmap entries that still have textures.
- I also added an `is_empty()` method to `TextureCache`, which is useful
for 3rd-party higher-level caches that might have individual caches by
view entity or texture type, for example.

## Testing

- Verified the examples still work (this is a trivial change)
2024-08-02 19:24:54 +02:00
..
macros Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
src Fix TextureCache memory leak and add is_empty() method (#14480) 2024-08-02 19:24:54 +02:00
Cargo.toml Release 0.14.0 version bump (#14126) 2024-07-03 18:22:10 -07:00
README.md Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00

Bevy Render

License Crates.io Downloads Docs Discord