现在在任务管理器中,我看到 6gb 中使用了 4.7gb 的 ram。
我使用这个类来获取我的 ram:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Management;
namespace ScreenVideoRecorder
{
class GetMemory
{
public static List<UInt32> DisplayTotalRam()
{
List<UInt32> uints = new List<UInt32>();
string Query = "SELECT MaxCapacity FROM Win32_PhysicalMemoryArray";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(Query);
foreach (ManagementObject WniPART in searcher.Get())
{
UInt32 SizeinKB = Convert.ToUInt32(WniPART.Properties["MaxCapacity"].Value);
UInt32 SizeinMB = SizeinKB / 1024;
UInt32 SizeinGB = SizeinMB / 1024;
//Console.WriteLine("Size in KB: {0}, Size in MB: {1}, Size in GB: {2}", SizeinKB, SizeinMB, SizeinGB);
uints.Add(SizeinKB);
uints.Add(SizeinMB);
uints.Add(SizeinGB);
}
return uints;
}
}
}
对于 Form1 中的测试,我做了:
List<UInt32> uints = GetMemory.DisplayTotalRam();
我现在看到在单位列表中使用断点:
index [0] i see: 33554432
index [1] i see: 32768
index [2] i see: 32
在任务管理器 4.7/6.0 (78%)
那么为什么我得到 32 ?(3.2GB)