mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
[AdvPaste]Clear image sources to fix memory leak (#33438)
* [AdvancedPaste] Clear image sources to fix memory leak
This commit is contained in:
parent
5c631bd2c7
commit
dcbff83d8c
@ -5,6 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AdvancedPaste.Helpers;
|
using AdvancedPaste.Helpers;
|
||||||
@ -86,6 +87,11 @@ namespace AdvancedPaste.Pages
|
|||||||
|
|
||||||
_dispatcherQueue.TryEnqueue(async () =>
|
_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();
|
clipboardHistory.Clear();
|
||||||
|
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
|
Loading…
Reference in New Issue
Block a user