⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memory.cs

📁 清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace CodeForChapter5cs
{
  class Memory
  {
    public static void ShowMemory()
    {
      MemoryStatus ms = new MemoryStatus();
      GlobalMemoryStatus(ms);

      string result =
        "Memory Load % = " + ms.MemoryLoad +
        "\r\nTotal Physical (KB) = " + ms.TotalPhysical / 1024 +
        "\r\nAvailable Physical (KB) = " + ms.AvailPhysical / 1024 +
        "\r\nTotal Virtual = (KB) " + ms.TotalVirtual / 1024 +
        "\r\nAvailalbe Virtual = (KB) " + ms.AvailVirtual / 1024;

      MessageBox.Show(result, GC.GetTotalMemory(false).ToString());
    }


    [DllImport("coredll.dll")]
    public static extern void GlobalMemoryStatus(MemoryStatus lpBuffer);

    public class MemoryStatus
    {
      public int Length;
      public int MemoryLoad;
      public int TotalPhysical;
      public int AvailPhysical;
      public int TotalPageFile;
      public int AvailPageFile;
      public int TotalVirtual;
      public int AvailVirtual;

      public MemoryStatus()
      {
        Length = Marshal.SizeOf(this);
      }
    }

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -