在WPF 项目中引用到Transitionals 实现图片转场特效,发现每次图片转场内存都会增加,在每次转场后进行内存压缩

记录 解决方案如下:

GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
  SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}

[DllImport("kernel32.dll")]
private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);

 

相关文章:

  • 2021-12-05
  • 2021-12-06
  • 2021-11-21
  • 2021-11-18
  • 2022-02-16
  • 2022-01-07
猜你喜欢
  • 2021-06-01
  • 2021-12-06
  • 2021-12-31
相关资源
相似解决方案