GC.GetTotalMemory(False)
获得系统内存的使用情况

解决方案 »

  1.   

    http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=6977HLMY-ELPN-4KIR-BI89-7YS2LNENT5HR
    这里有vb的,很容易翻成cs的
      

  2.   

    System.Diagnostics.Process类下有如下方法:
    PagedMemorySize 获取分页的内存大小。 
    PagedSystemMemorySize 获取分页的系统内存大小。 
    PeakPagedMemorySize 获取峰值分页内存大小。 
    PeakVirtualMemorySize 获取峰值虚拟内存大小。 
    VirtualMemorySize 获取进程的虚拟内存大小。 
    WorkingSet 获取关联进程的物理内存使用情况。 
    .....
    Process 组件是很有用的工具。使用 Process 组件,可以获取当前运行的进程的列表,或者启动新的进程。Process 组件用于访问系统进程。初始化 Process 组件后,可使用该组件来获取有关当前运行的进程的信息。此类信息包括线程集、加载的模块(.dll 和 .exe 文件)和性能信息(如进程当前使用的内存量)。
      

  3.   

    那请问当前cpu的使用率 用什么函数可以查到?
      

  4.   

    这个是孟老大的
    取得cpu的利用率:
    using System;
    using System.Diagnostics;
    using System.Threading;
    public class CpuLoadInfo
    { // auxiliary print methods
     private static void Say ( string txt )
     {
      Console.WriteLine(txt);
     } // auxiliary print methods
     private static void Say()
     {
      Say("");
     } // The main method. Command line arguments are ignored.
     [STAThread]
     public static void Main()
     {
      Say("$Id: CpuLoadInfo.cs,v 1.2 2002/08/17 17:45:48 rz65 Exp $");
      Say();  Say("Attempt to create a PerformanceCounter instance:");
      Say("Category name = " + CategoryName);
      Say("Counter name  = " + CounterName);
      Say("Instance name = " + InstanceName);
      PerformanceCounter pc
       = new PerformanceCounter(CategoryName,CounterName,InstanceName);
      Say("Performance counter was created.");
      Say("Property CounterType: " + pc.CounterType);
      Say();  Say("Property CounterHelp: " + pc.CounterHelp);
      Say();
      Say("Entering measurement loop.");  while (true)
      {
       Thread.Sleep(1000); // wait for 1 second
       float cpuLoad = pc.NextValue();
       Say("CPU load = " + cpuLoad + " %.");
      }
     } // constants used to select the performance counter.
     private const string CategoryName = "Processor";
     private const string CounterName  = "% Processor Time";
     private const string InstanceName = "_Total";
    }