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

相关文章:

  • 2021-12-01
  • 2021-09-23
  • 2021-07-27
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-11
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案