[NTOSKRNL]
authorCameron Gutman <aicommander@gmail.com>
Mon, 19 Dec 2011 08:49:42 +0000 (08:49 +0000)
committerCameron Gutman <aicommander@gmail.com>
Mon, 19 Dec 2011 08:49:42 +0000 (08:49 +0000)
- Tweak the balancer a bit to favor RosMm allocations in low memory scenarios
- Fix the balancer out of memory warning

svn path=/trunk/; revision=54693

reactos/ntoskrnl/mm/balance.c

index 5879dda..471e11d 100644 (file)
@@ -108,8 +108,7 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
    {
       if(Consumer == MC_USER) MmRemoveLRUUserPage(Page);
       (void)InterlockedDecrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
-      if (MmAvailablePages < MiMinimumAvailablePages ||
-            (Entry = ExInterlockedRemoveHeadList(&AllocationListHead, &AllocationListLock)) == NULL)
+      if ((Entry = ExInterlockedRemoveHeadList(&AllocationListHead, &AllocationListLock)) == NULL)
       {
          OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
          MmDereferencePage(Page);
@@ -166,9 +165,6 @@ MiTrimMemoryConsumer(ULONG Consumer)
 
         DPRINT("Trimming consumer %d: Freed %d pages with a target of %d pages\n", Consumer, NrFreedPages, Target);
 
-        if (NrFreedPages == 0)
-            DPRINT1("Ran out of pages to swap!\n");
-
         if (!NT_SUCCESS(Status))
         {
             KeBugCheck(MEMORY_MANAGEMENT);
@@ -356,6 +352,12 @@ MiBalancerThread(PVOID Unused)
           {
               MiTrimMemoryConsumer(i);
           }
+
+          if (MmAvailablePages < MiMinimumAvailablePages)
+          {
+              /* This is really bad... */
+              DPRINT1("Balancer failed to resolve low memory condition! Complete memory exhaustion is imminent!\n");
+          }
       }
       else
       {