コード例 #1
0
 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;
 }
コード例 #3
0
        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
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 internal extern static int GlobalMemoryStatusEx(ref MEMORYSTATUSEX memoryStatusEx);
コード例 #6
0
        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;
        }
コード例 #7
0
 internal extern static int GlobalMemoryStatusEx(ref MEMORYSTATUSEX memoryStatusEx);