Index: /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp	(revision 37802)
+++ /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp	(revision 37803)
@@ -2657,5 +2657,5 @@
                                 /* else: NIL_RTHCPHYS nothing */
 
-                                paPages[iPage].idPage = NIL_GMM_PAGEID;
+                                paPages[iPage].idPage       = NIL_GMM_PAGEID;
                                 paPages[iPage].HCPhysGCPhys = NIL_RTHCPHYS;
                             }
@@ -2722,11 +2722,39 @@
                     }
                 }
+            } /* for each page to update */
+
+            if (RT_SUCCESS(rc))
+            {
+#if 0  /* This appears to spell trouble... weird. */
+                for (iPage = 0; iPage < cPagesToAlloc; iPage++)
+                {
+                    Assert(paPages[iPage].HCPhysGCPhys  == NIL_RTHCPHYS);
+                    Assert(paPages[iPage].idPage        == NIL_GMM_PAGEID);
+                    Assert(paPages[iPage].idSharedPage  == NIL_GMM_PAGEID);
+                }
+#endif
+
+                /*
+                 * Join paths with GMMR0AllocatePages for the allocation.
+                 * Note! gmmR0AllocateMoreChunks may leave the protection of the mutex!
+                 */
+#if 0  /* Trying to reproduce out of memory issue... */
+                if (!cPagesToUpdate)
+#endif
+                    rc = gmmR0AllocatePagesNew(pGMM, pGVM, cPagesToAlloc, paPages, GMMACCOUNT_BASE);
+#if 0  /* Trying to reproduce out of memory issue... */
+                else
+                {
+                    for (iPage = 0; iPage < cPagesToAlloc; iPage++)
+                    {
+                        paPages[iPage].HCPhysGCPhys  = NIL_RTHCPHYS;
+                        paPages[iPage].idPage        = NIL_GMM_PAGEID;
+                        paPages[iPage].idSharedPage  = NIL_GMM_PAGEID;
+                    }
+
+                    rc = VERR_GMM_HIT_VM_ACCOUNT_LIMIT;
+                }
+#endif
             }
-
-            /*
-             * Join paths with GMMR0AllocatePages for the allocation.
-             * Note! gmmR0AllocateMoreChunks may leave the protection of the mutex!
-             */
-            rc = gmmR0AllocatePagesNew(pGMM, pGVM, cPagesToAlloc, paPages, GMMACCOUNT_BASE);
         }
         else
Index: /trunk/src/VBox/VMM/VMMR0/PGMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/PGMR0.cpp	(revision 37802)
+++ /trunk/src/VBox/VMM/VMMR0/PGMR0.cpp	(revision 37803)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2007-2010 Oracle Corporation
+ * Copyright (C) 2007-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -121,8 +121,8 @@
             do
             {
-                cPages >>= 2;
+                cPages >>= 1;
                 if (cPages + iFirst < PGM_HANDY_PAGES_MIN)
                     cPages = PGM_HANDY_PAGES_MIN - iFirst;
-                rc = GMMR0AllocateHandyPages(pVM, pVCpu->idCpu, cPages, cPages, &pVM->pgm.s.aHandyPages[iFirst]);
+                rc = GMMR0AllocateHandyPages(pVM, pVCpu->idCpu, 0, cPages, &pVM->pgm.s.aHandyPages[iFirst]);
             } while (   (   rc == VERR_GMM_HIT_GLOBAL_LIMIT
                          || rc == VERR_GMM_HIT_VM_ACCOUNT_LIMIT)
Index: /trunk/src/VBox/VMM/VMMR3/PGM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/PGM.cpp	(revision 37802)
+++ /trunk/src/VBox/VMM/VMMR3/PGM.cpp	(revision 37803)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -1196,4 +1196,18 @@
     pVM->pgm.s.offVM       = RT_OFFSETOF(VM, pgm.s);
     pVM->pgm.s.offVCpuPGM  = RT_OFFSETOF(VMCPU, pgm.s);
+
+    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.aHandyPages); i++)
+    {
+        pVM->pgm.s.aHandyPages[i].HCPhysGCPhys  = NIL_RTHCPHYS;
+        pVM->pgm.s.aHandyPages[i].idPage        = NIL_GMM_PAGEID;
+        pVM->pgm.s.aHandyPages[i].idSharedPage  = NIL_GMM_PAGEID;
+    }
+
+    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.aLargeHandyPage); i++)
+    {
+        pVM->pgm.s.aLargeHandyPage[i].HCPhysGCPhys  = NIL_RTHCPHYS;
+        pVM->pgm.s.aLargeHandyPage[i].idPage        = NIL_GMM_PAGEID;
+        pVM->pgm.s.aLargeHandyPage[i].idSharedPage  = NIL_GMM_PAGEID;
+    }
 
     /* Init the per-CPU part. */
