Ejemplo n.º 1
0
 static CacheMemoryPressure() {
     UnsafeNativeMethods.MEMORYSTATUSEX  memoryStatusEx = new UnsafeNativeMethods.MEMORYSTATUSEX();
     memoryStatusEx.Init();
     if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) != 0) {
         s_totalPhysical = memoryStatusEx.ullTotalPhys;
         s_totalVirtual = memoryStatusEx.ullTotalVirtual;
     }
 }
 protected override int GetCurrentPressure()
 {
     UnsafeNativeMethods.MEMORYSTATUSEX memoryStatusEx = new UnsafeNativeMethods.MEMORYSTATUSEX();
     memoryStatusEx.Init();
     if (UnsafeNativeMethods.GlobalMemoryStatusEx(ref memoryStatusEx) == 0)
     {
         return 0;
     }
     int dwMemoryLoad = memoryStatusEx.dwMemoryLoad;
     if (base._pressureHigh != 0)
     {
         PerfCounters.SetCounter(AppPerfCounter.CACHE_PERCENT_MACH_MEM_LIMIT_USED, dwMemoryLoad);
     }
     return dwMemoryLoad;
 }
Ejemplo n.º 3
0
        override protected int GetCurrentPressure() {
            UnsafeNativeMethods.MEMORYSTATUSEX  memoryStatusEx = new UnsafeNativeMethods.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;
        }