使.NET应用程序的RAM大小免费

时间:2014-06-26 07:12:09

标签: c# .net ram

我在WPF表单上创建了一些网格图像,如小册子页面。当我运行我的应用程序时,系统RAM内存大小为1.02 GB(包括所有其他正在运行的应用程序)。当我翻页时,RAM大小增加了一些kb。最后,当我翻了150多页时,我得到了Out Of Memory异常。我理解异常是由于RAM中没有空间在我的应用程序上打开新页面而我尝试了以下内容:

     1. BitmapImage image = new BitmapImage();
        image.Dispose();
        image = null;


     2. Gc.Collect();



    3.[DllImport("psapi.dll")]
    public static extern bool EmptyWorkingSet(IntPtr hProcess);

public FreeMem(string programName){

      EmptyWorkingSet(Process.GetCurrentProcess().Handle);
      foreach(Process process in Process.GetProcesses(programName))
      {
            try
            {
                EmptyWorkingSet(process.Handle);
            }
            catch (Exception)
            {
                ...
            }
      } 
}

但我无法解决我的问题。谁能让我清楚并解决这个问题?

0 个答案:

没有答案