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); }
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; } } }
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); }
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); }
internal static extern bool GlobalMemoryStatusEx( ref NativeMethods.MemoryStatusEx buffer);
public Memory() { _status = new NativeMethods.MemoryStatusEx(); }
public MemoryInfo() { _memoryStatus = new NativeMethods.MemoryStatusEx(); NativeMethods.GlobalMemoryStatusEx(_memoryStatus); }