protected override int GetCurrentPressure() { #if MONO var pc = new System.Diagnostics.PerformanceCounter("Mono Memory", "Available Physical Memory"); long availableMemory = pc.RawValue; int memoryLoad = (int)((100 * availableMemory) / TotalPhysical); #else MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0) { return(0); } int memoryLoad = memoryStatusEx.dwMemoryLoad; #endif //if (_pressureHigh != 0) { // PerfCounter: Cache Percentage Machine Memory Limit Used // = total physical memory used / total physical memory used limit //PerfCounters.SetCounter(AppPerfCounter.CACHE_PERCENT_MACH_MEM_LIMIT_USED, memoryLoad); //} return(memoryLoad); }
static MemoryMonitor() { MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) != 0) { s_totalPhysical = memoryStatusEx.ullTotalPhys; s_totalVirtual = memoryStatusEx.ullTotalVirtual; } }
protected override int GetCurrentPressure() { MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0) { return 0; } return memoryStatusEx.dwMemoryLoad; }
static MemoryMonitor() { MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) != 0) { s_totalPhysical = memoryStatusEx.ullTotalPhys; s_totalVirtual = memoryStatusEx.ullTotalVirtual; } }
protected override int GetCurrentPressure() { MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0) { return(0); } return(memoryStatusEx.dwMemoryLoad); }
static MemoryMonitor() { #if MONO var pc = new System.Diagnostics.PerformanceCounter ("Mono Memory", "Total Physical Memory"); s_totalPhysical = pc.RawValue; // We should set the the total virtual memory with a system value. // But Mono has no such PerformanceCounter and the total virtual memory has little relevance // for the rest of the System.Runtime.Caching code. s_totalVirtual = 0; #else MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) != 0) { s_totalPhysical = memoryStatusEx.ullTotalPhys; s_totalVirtual = memoryStatusEx.ullTotalVirtual; } #endif }
protected override int GetCurrentPressure() { MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0) { return(0); } int memoryLoad = memoryStatusEx.dwMemoryLoad; //if (_pressureHigh != 0) { // PerfCounter: Cache Percentage Machine Memory Limit Used // = total physical memory used / total physical memory used limit //PerfCounters.SetCounter(AppPerfCounter.CACHE_PERCENT_MACH_MEM_LIMIT_USED, memoryLoad); //} return(memoryLoad); }
static MemoryMonitor() { #if MONO var pc = new System.Diagnostics.PerformanceCounter("Mono Memory", "Total Physical Memory"); s_totalPhysical = pc.RawValue; // We should set the the total virtual memory with a system value. // But Mono has no such PerformanceCounter and the total virtual memory has little relevance // for the rest of the System.Runtime.Caching code. s_totalVirtual = 0; #else MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) != 0) { s_totalPhysical = memoryStatusEx.ullTotalPhys; s_totalVirtual = memoryStatusEx.ullTotalVirtual; } #endif }
protected override int GetCurrentPressure() { #if MONO var pc = new System.Diagnostics.PerformanceCounter ("Mono Memory", "Available Physical Memory"); long availableMemory = pc.RawValue; int memoryLoad = (int) ((100 * availableMemory) / TotalPhysical); #else MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0) return 0; int memoryLoad = memoryStatusEx.dwMemoryLoad; #endif //if (_pressureHigh != 0) { // PerfCounter: Cache Percentage Machine Memory Limit Used // = total physical memory used / total physical memory used limit //PerfCounters.SetCounter(AppPerfCounter.CACHE_PERCENT_MACH_MEM_LIMIT_USED, memoryLoad); //} return memoryLoad; }
protected override int GetCurrentPressure() { MEMORYSTATUSEX memoryStatusEx = new MEMORYSTATUSEX(); memoryStatusEx.Init(); if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0) return 0; int memoryLoad = memoryStatusEx.dwMemoryLoad; //if (_pressureHigh != 0) { // PerfCounter: Cache Percentage Machine Memory Limit Used // = total physical memory used / total physical memory used limit //PerfCounters.SetCounter(AppPerfCounter.CACHE_PERCENT_MACH_MEM_LIMIT_USED, memoryLoad); //} return memoryLoad; }