解决方法如下:

-- in class definition (在类中引用)
 
        [DllImport("KERNEL32.DLL", EntryPoint = "SetProcessWorkingSetSize", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
        internal static extern bool SetProcessWorkingSetSize(IntPtr pProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);
 
        [DllImport("KERNEL32.DLL", EntryPoint = "GetCurrentProcess", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
        internal static extern IntPtr GetCurrentProcess();
 
-- code to call when you want to reduce the memory(在方法中执行)
 
            IntPtr pHandle = GetCurrentProcess();
            SetProcessWorkingSetSize(pHandle, -1, -1);

 

相关文章:

  • 2021-09-18
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-06-03
  • 2021-12-14
  • 2021-08-05
猜你喜欢
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
相关资源
相似解决方案