Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            CathegoryOfMemory status               = CathegoryOfMemory.CreateInstance();
            double            MemoryLoad           = status.MemoryLoad;
            double            TotalPhys            = status.TotalPhys;
            double            AvailPhys            = status.AvailPhys;
            double            TotalPageFile        = status.TotalPageFile;
            double            AvailPageFile        = status.AvailPageFile;
            double            TotalVirtual         = status.TotalVirtual;
            double            AvailVirtual         = status.AvailVirtual;
            double            AvailExtendedVirtual = status.AvailExtendedVirtual;

            listBox1.Items.Add("1. Total RAM: " + Math.Round(TotalPhys / 1024 / 1024, 2) + " MB");
            listBox1.Items.Add("2. Free RAM space: " + Math.Round(AvailPhys / 1024 / 1024, 2) + " MB");
            listBox1.Items.Add("3. Swap file size: " + Math.Round(TotalPageFile / 1024 / 1024, 2) + " MB");
            listBox1.Items.Add("4. Free swap file space : " + Math.Round(AvailPageFile / 1024 / 1024, 2) + " MB");
            listBox1.Items.Add("5. Total virtual memory: " + Math.Round(TotalVirtual / 1024 / 1024, 2) + " MB");
            listBox1.Items.Add("6. Free virtual memory space: " + Math.Round(AvailVirtual / 1024 / 1024, 2) + " MB");
            listBox1.Items.Add("7. Memory involved in this process: " + Math.Round(MemoryLoad / 1024 / 1024, 4) + " MB");

            List <double> statuses = new List <double>()
            {
                TotalPhys, AvailPhys, TotalPageFile, AvailPageFile, TotalVirtual, AvailVirtual, MemoryLoad
            };

            this.chart1.Series["Распределение памяти"].Points.DataBindY(statuses);
        }
Пример #2
0
 public static CathegoryOfMemory CreateInstance()
 {
     if (singleton == null)
     {
         lock (syncroot)
             if (singleton == null)
             {
                 singleton = new CathegoryOfMemory();
             }
     }
     return(singleton);
 }
Пример #3
0
 internal static extern bool GlobalMemoryStatusEx([In, Out] CathegoryOfMemory lpBuffer);