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

📄 gc.cs

📁 c#的学习资料 书上的东西 很难找到的啊
💻 CS
字号:
//
// gc.cs -- Demonstrates forced garbage collection
//
//          Compile this program with the following command line:
//              C:>csc gc.cs
//
namespace nsGarbage
{
    using System;
    using System.Threading;
    class clsMain
    {
        static public void Main ()
        {
            long Mem = GC.GetTotalMemory (false);
            Console.WriteLine ("Beginning allocated memory is " + Mem);
            for (int x = 0; x < 10000; ++x)
            {
                clsClass howdy = new clsClass();
            }
            Mem = GC.GetTotalMemory (false);
            Console.WriteLine ("Allocated memory before garbage collection is " + Mem);
            GC.Collect ();
            Mem = GC.GetTotalMemory (true);
            Console.WriteLine ("Allocated memory after garbage collection is " + Mem);
        }
    }
    class clsClass
    {
        public clsClass () { }
        public int x = 42;
        public float f = 2E10f;
        public double d = 3.14159;
        public string str = "This here's a string";
    }
}

⌨️ 快捷键说明

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