Browse Source

Merge pull request #415 from ionite34/fix-memoryinfo

pull/339/head
Ionite 11 months ago committed by GitHub
parent
commit
c14ab62432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 6
      StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs
  3. 22
      StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs

1
CHANGELOG.md

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
## v2.7.3
### Fixed
- Fixed UnicodeDecodeError when using extra_model_paths.yaml in ComfyUI on certain locales
- Fixed [#334](https://github.com/LykosAI/StabilityMatrix/issues/334) - Win32Exception if Settings are opened
## v2.7.2
### Changed

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

@ -212,7 +212,6 @@ public partial class MainSettingsViewModel : PageViewModelBase
base.OnLoaded();
hardwareInfoUpdateTimer.Start();
OnHardwareInfoUpdateTimerTick(null, null!);
}
/// <inheritdoc />
@ -236,7 +235,10 @@ public partial class MainSettingsViewModel : PageViewModelBase
private void OnHardwareInfoUpdateTimerTick(object? sender, EventArgs e)
{
MemoryInfo = HardwareHelper.GetMemoryInfo();
if (HardwareHelper.IsMemoryInfoAvailable && HardwareHelper.TryGetMemoryInfo(out var newMemoryInfo))
{
MemoryInfo = newMemoryInfo;
}
}
partial void OnSelectedThemeChanged(string? value)

22
StabilityMatrix.Core/Helper/HardwareInfo/HardwareHelper.cs

@ -5,11 +5,14 @@ using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using Hardware.Info;
using Microsoft.Win32;
using NLog;
namespace StabilityMatrix.Core.Helper.HardwareInfo;
public static partial class HardwareHelper
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static IReadOnlyList<GpuInfo>? cachedGpuInfos;
private static readonly Lazy<IHardwareInfo> HardwareInfoLazy = new(() => new Hardware.Info.HardwareInfo());
@ -149,6 +152,25 @@ public static partial class HardwareHelper
// Set DirectML for default if AMD and Windows
public static bool PreferDirectML() => !HasNvidiaGpu() && HasAmdGpu() && Compat.IsWindows;
private static readonly Lazy<bool> IsMemoryInfoAvailableLazy = new(() => TryGetMemoryInfo(out _));
public static bool IsMemoryInfoAvailable => IsMemoryInfoAvailableLazy.Value;
public static bool TryGetMemoryInfo(out MemoryInfo memoryInfo)
{
try
{
memoryInfo = GetMemoryInfo();
return true;
}
catch (Exception ex)
{
Logger.Warn(ex, "Failed to get memory info");
memoryInfo = default;
return false;
}
}
/// <summary>
/// Gets the total and available physical memory in bytes.
/// </summary>

Loading…
Cancel
Save