Esempio n. 1
0
 private static unsafe void DoEviction(object stateInfo)
 {
     while (true)
     {
         try
         {
             MEMORYSTATUSEX memStatus = new MEMORYSTATUSEX();
             memStatus.dwLength = (UInt32)sizeof(MEMORYSTATUSEX);
             HpcLinqNative.GlobalMemoryStatusEx(ref memStatus);
             if (HpcLinqNative.GlobalMemoryStatusEx(ref memStatus) &&
                 memStatus.ullAvailPhys < 4 * 1024 * 1024 * 1024UL)
             {
                 // Perform eviction only when feeling memory pressure
                 lock (s_cache)
                 {
                     var candidates = s_cache.Where(x => x.Value.RefCount == 0);
                     foreach (var rec in candidates)
                     {
                         s_cache.Remove(rec.Key);
                     }
                 }
             }
         }
         catch (Exception e)
         {
             DryadLinqLog.Add("Exception occurred when performing cache eviction: {0}.",
                            e.Message);
         }
     }
 }
Esempio n. 2
0
 internal static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
Esempio n. 3
0
 internal static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);