mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add Options::reduce_texture_memory to free up RAM (#4431)
## Summary This PR introduces a new configuration option `reduce_texture_memory` in `egui`. ## Changes - Added `reduce_texture_memory` option in `egui`. When set to `true`, `egui` will discard the loaded image data after the texture is uploaded to the GPU, reducing memory usage. This is beneficial when handling a large number of images and retaining the image data is unnecessary, potentially saving substantial memory. However, this makes it impossible to serialize the loaded images or render on non-GPU systems. Default is `false`. ## Impact This new configuration option gives users more control over their memory usage, especially when dealing with a large number or large resolution of images. It allows users to optimize their applications based on their specific needs and constraints.
This commit is contained in:
@@ -184,6 +184,11 @@ impl eframe::App for ImageViewer {
|
||||
ui.add_space(5.0);
|
||||
ui.label("Aspect ratio is maintained by scaling both sides as necessary");
|
||||
ui.checkbox(&mut self.maintain_aspect_ratio, "Maintain aspect ratio");
|
||||
|
||||
// forget all images
|
||||
if ui.button("Forget all images").clicked() {
|
||||
ui.ctx().forget_all_images();
|
||||
}
|
||||
});
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
|
||||
Reference in New Issue
Block a user