C# 获取应用程序内存

 double usedMemory = 0;
            Process p = Process.GetProcesses().Where(x => x.ProcessName.Contains("进程名")).FirstOrDefault();
            if (p != null)
            {
                p.Refresh();
                string procName = p.ProcessName;
                using (PerformanceCounter pc = new PerformanceCounter("Process", "Working Set - Private", procName))
                {
                    usedMemory = pc.NextValue() / 1024.0 / 1024.0;
                }
            }
原文地址:https://www.cnblogs.com/swarb/p/9924269.html