From 31c36afc4ce5dedc912a74e7334e8d3f36faed4c Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Fri, 21 Jul 2023 18:42:49 -0700 Subject: [PATCH] Ensure CimSession is properly disposed. --- src/Ryujinx.Common/SystemInfo/SystemInfo.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Common/SystemInfo/SystemInfo.cs b/src/Ryujinx.Common/SystemInfo/SystemInfo.cs index 45301de6a..24a745a47 100644 --- a/src/Ryujinx.Common/SystemInfo/SystemInfo.cs +++ b/src/Ryujinx.Common/SystemInfo/SystemInfo.cs @@ -93,11 +93,13 @@ namespace Ryujinx.Common.SystemInfo { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var session = CimSession.Create(null); - var instances = session.QueryInstances(@"root\cimv2", "WQL", "SELECT NumberOfCores FROM Win32_Processor"); - foreach (CimInstance instance in instances) + using (var session = CimSession.Create(null)) { - coreCount = int.Parse(instance.CimInstanceProperties["NumberOfCores"].Value.ToString()); + var instances = session.QueryInstances(@"root\cimv2", "WQL", "SELECT NumberOfCores FROM Win32_Processor"); + foreach (CimInstance instance in instances) + { + coreCount = int.Parse(instance.CimInstanceProperties["NumberOfCores"].Value.ToString()); + } } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))