Exemplo n.º 1
0
        public override void Update()
        {
            NativeMethods.MemoryStatusEx status = new NativeMethods.MemoryStatusEx();
            status.Length = checked ((uint)Marshal.SizeOf(typeof(NativeMethods.MemoryStatusEx)));

            if (!NativeMethods.GlobalMemoryStatusEx(ref status))
            {
                return;
            }

            loadSensor.Value = 100.0f - (100.0f * status.AvailablePhysicalMemory) / status.TotalPhysicalMemory;

            usedMemory.Value = (float)(status.TotalPhysicalMemory - status.AvailablePhysicalMemory) / (1024 * 1024 * 1024);

            availableMemory.Value = (float)status.AvailablePhysicalMemory / (1024 * 1024 * 1024);
        }
Exemplo n.º 2
0
        public override void Update()
        {
            NativeMethods.MemoryStatusEx status = new NativeMethods.MemoryStatusEx
            {
                Length = checked ((uint)Marshal.SizeOf(
                                      typeof(NativeMethods.MemoryStatusEx)))
            };

            if (sensorConfig.GetSensorEvaluate(usedMemory.IdentifierString) ||
                sensorConfig.GetSensorEvaluate(availableMemory.IdentifierString) ||
                sensorConfig.GetSensorEvaluate(loadSensor.IdentifierString))
            {
                if (!NativeMethods.GlobalMemoryStatusEx(ref status))
                {
                    return;
                }

                loadSensor.Value = 100.0f -
                                   (100.0f * status.AvailablePhysicalMemory) /
                                   status.TotalPhysicalMemory;

                usedMemory.Value = (status.TotalPhysicalMemory
                                    - status.AvailablePhysicalMemory) / SCALE;

                availableMemory.Value = status.AvailablePhysicalMemory / SCALE;
            }

            if (sensorConfig.GetSensorEvaluate(usedMemoryProcess.IdentifierString))
            {
                lock (_performanceCounterLock)
                {
                    usedMemoryProcess.Value = ramUsageGamePerformanceCounter != null
                    ? ramUsageGamePerformanceCounter.NextValue() / SCALE : 0f;
                }
            }

            if (sensorConfig.GetSensorEvaluate(usedMemoryAndCacheProcess.IdentifierString))
            {
                lock (_performanceCounterLock)
                {
                    usedMemoryAndCacheProcess.Value = ramAndCacheUsageGamePerformanceCounter != null
                    ? ramAndCacheUsageGamePerformanceCounter.NextValue() / SCALE : 0f;
                }
            }
        }
Exemplo n.º 3
0
    public override void Update() {
      NativeMethods.MemoryStatusEx status = new NativeMethods.MemoryStatusEx();
      status.Length = checked((uint)Marshal.SizeOf(
          typeof(NativeMethods.MemoryStatusEx)));

      if (!NativeMethods.GlobalMemoryStatusEx(ref status))
        return;

      loadSensor.Value = 100.0f -
        (100.0f * status.AvailablePhysicalMemory) /
        status.TotalPhysicalMemory;

      usedMemory.Value = (float)(status.TotalPhysicalMemory 
        - status.AvailablePhysicalMemory) / (1024 * 1024 * 1024);

      availableMemory.Value = (float)status.AvailablePhysicalMemory /
        (1024 * 1024 * 1024);
    }
Exemplo n.º 4
0
        public void Update()
        {
            NativeMethods.MemoryStatusEx status = new NativeMethods.MemoryStatusEx
            {
                Length = checked ((uint)Marshal.SizeOf(
                                      typeof(NativeMethods.MemoryStatusEx)))
            };

            if (!NativeMethods.GlobalMemoryStatusEx(ref status))
            {
                return;
            }

            load = 100.0f -
                   (100.0f * status.AvailablePhysicalMemory) /
                   status.TotalPhysicalMemory;

            used = (float)(status.TotalPhysicalMemory
                           - status.AvailablePhysicalMemory) / (1024 * 1024 * 1024);

            total = (float)status.TotalPhysicalMemory /
                    (1024 * 1024 * 1024);
        }
Exemplo n.º 5
0
 internal static extern bool GlobalMemoryStatusEx(
     ref NativeMethods.MemoryStatusEx buffer);
Exemplo n.º 6
0
 public Memory()
 {
     _status = new NativeMethods.MemoryStatusEx();
 }
Exemplo n.º 7
0
 public MemoryInfo()
 {
     _memoryStatus = new NativeMethods.MemoryStatusEx();
     NativeMethods.GlobalMemoryStatusEx(_memoryStatus);
 }