WPF 内存释放

在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);

 

posted on 2018-01-16 14:26  Kenny_qiu  阅读(2334)  评论(0编辑  收藏  举报