https://zhidao.baidu.com/question/31914620.html
https://www.cnblogs.com/xcsn/p/4678322.html
Process CurrentProcess = Process.GetCurrentProcess();
CurrentProcess.Id.ToString();//PID
((Double)(CurrentProcess.TotalProcessorTime.TotalMilliseconds-CurrentProcess.UserProcessorTime.TotalMilliseconds)).ToString();//CPU
(CurrentProcess.WorkingSet64 / 1024 / 1024).ToString() + "M (" + (CurrentProcess.WorkingSet64 / 1024).ToString() + "KB)";//占用内存
CurrentProcess.Threads.Count.ToString();//线程
#region 内存回收
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
/// <summary>
/// 释放内存
/// </summary>
public static void ClearMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
App.SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
#endregion