bevy/crates/bevy_render/src/texture
Brian Reavis 724fe49c73
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-07-27 13:16:27 +00:00
..
basis.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
compressed_image_saver.rs Use async-fn in traits rather than BoxedFuture (#12550) 2024-03-18 17:56:57 +00:00
dds.rs Fixed a bug where skybox ddsfile would crash from wgpu (#12894) 2024-04-08 17:16:25 +00:00
exr_texture_loader.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
fallback_image.rs Prefer UVec2 when working with texture dimensions (#11698) 2024-02-25 15:23:04 +00:00
hdr_texture_loader.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
image.rs Fix breaking image 0.25.2 release. (#14421) 2024-07-21 21:27:07 +00:00
image_loader.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
image_texture_conversion.rs Remove redundant imports (#12817) 2024-04-01 19:59:08 +00:00
ktx2.rs Apply Clippy lints regarding lazy evaluation and closures (#14015) 2024-07-01 15:54:40 +00:00
mod.rs Make default behavior for BackgroundColor and BorderColor more intuitive (#14017) 2024-06-25 21:50:41 +00:00
texture_attachment.rs Allow mix of hdr and non-hdr cameras to same render target (#13419) 2024-06-06 20:55:05 +00:00
texture_cache.rs Fix TextureCache memory leak and add is_empty() method (#14480) 2024-07-27 13:16:27 +00:00