Browse Source

Add Debug GC Collect and clear image cache commands

pull/629/head
Ionite 9 months ago
parent
commit
a15dd34d97
No known key found for this signature in database
  1. 9
      StabilityMatrix.Avalonia/FallbackRamCachedWebImageLoader.cs
  2. 20
      StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs

9
StabilityMatrix.Avalonia/FallbackRamCachedWebImageLoader.cs

@ -103,4 +103,13 @@ public class FallbackRamCachedWebImageLoader : RamCachedWebImageLoader
} }
} }
} }
public void ClearCache()
{
var cache =
this.GetPrivateField<ConcurrentDictionary<string, Task<Bitmap?>>>("_memoryCache")
?? throw new NullReferenceException("Memory cache not found");
cache.Clear();
}
} }

20
StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs

@ -14,6 +14,7 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using AsyncImageLoader;
using Avalonia; using Avalonia;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
@ -774,7 +775,9 @@ public partial class MainSettingsViewModel : PageViewModelBase
[ [
new CommandItem(DebugFindLocalModelFromIndexCommand), new CommandItem(DebugFindLocalModelFromIndexCommand),
new CommandItem(DebugExtractDmgCommand), new CommandItem(DebugExtractDmgCommand),
new CommandItem(DebugShowNativeNotificationCommand) new CommandItem(DebugShowNativeNotificationCommand),
new CommandItem(DebugClearImageCacheCommand),
new CommandItem(DebugGCCollectCommand)
]; ];
[RelayCommand] [RelayCommand]
@ -889,6 +892,21 @@ public partial class MainSettingsViewModel : PageViewModelBase
); );
} }
[RelayCommand]
private void DebugClearImageCache()
{
if (ImageLoader.AsyncImageLoader is FallbackRamCachedWebImageLoader loader)
{
loader.ClearCache();
}
}
[RelayCommand]
private void DebugGCCollect()
{
GC.Collect();
}
#endregion #endregion
#region Info Section #region Info Section

Loading…
Cancel
Save