Ensure CimSession is properly disposed.

This commit is contained in:
sunshineinabox 2023-07-21 18:42:49 -07:00
parent cc8f4f8a11
commit 31c36afc4c

View file

@ -93,13 +93,15 @@ namespace Ryujinx.Common.SystemInfo
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
var session = CimSession.Create(null); using (var session = CimSession.Create(null))
{
var instances = session.QueryInstances(@"root\cimv2", "WQL", "SELECT NumberOfCores FROM Win32_Processor"); var instances = session.QueryInstances(@"root\cimv2", "WQL", "SELECT NumberOfCores FROM Win32_Processor");
foreach (CimInstance instance in instances) foreach (CimInstance instance in instances)
{ {
coreCount = int.Parse(instance.CimInstanceProperties["NumberOfCores"].Value.ToString()); coreCount = int.Parse(instance.CimInstanceProperties["NumberOfCores"].Value.ToString());
} }
} }
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ {
string cpuCoresLine = File.ReadLines("/proc/cpuinfo").FirstOrDefault(line => line.Contains("cpu cores")); string cpuCoresLine = File.ReadLines("/proc/cpuinfo").FirstOrDefault(line => line.Contains("cpu cores"));