diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml.cs b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml.cs index 1aa49c1014..8926cb1820 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml.cs +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using System.Threading; using System.Threading.Tasks; using AdvancedPaste.Helpers; @@ -86,6 +87,11 @@ namespace AdvancedPaste.Pages _dispatcherQueue.TryEnqueue(async () => { + // Clear to avoid leaks due to Garbage Collection not clearing the bitmap from memory. Fix for https://github.com/microsoft/PowerToys/issues/33423 + clipboardHistory.Where(x => x.Image is not null) + .ToList() + .ForEach(x => x.Image.ClearValue(BitmapImage.UriSourceProperty)); + clipboardHistory.Clear(); foreach (var item in items)