win32_get_avail_memory(): Report 85% of minimum of virtual and physical memory
authorEric Biggers <ebiggers3@gmail.com>
Sun, 26 Oct 2014 23:55:44 +0000 (18:55 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 26 Oct 2014 23:58:02 +0000 (18:58 -0500)
This should be a better prediction of how much memory can actually be
allocated.

src/win32_replacements.c

index b282768d3edc1f3473967f3252167aa4226efa32..ebf6e20e6cc2d4414b6270df65f7a3a214893982 100644 (file)
@@ -73,7 +73,7 @@ win32_get_avail_memory(void)
                .dwLength = sizeof(status),
        };
        GlobalMemoryStatusEx(&status);
-       return status.ullTotalPhys;
+       return (u64)min(status.ullTotalPhys, status.ullTotalVirtual) * 85 / 100;
 }
 
 /* Replacement for POSIX-2008 realpath().  Warning: partial functionality only