--- old/src/os/windows/vm/os_windows.cpp 2013-03-15 21:54:28.299485050 +0100 +++ new/src/os/windows/vm/os_windows.cpp 2013-03-15 21:54:28.171485056 +0100 @@ -685,12 +685,17 @@ return win32::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { +bool os::has_allocatable_memory_limit(julong* limit) { + MEMORYSTATUSEX ms; + ms.dwLength = sizeof(ms); + GlobalMemoryStatusEx(&ms); #ifdef _LP64 - return size; + *limit = (julong)ms.ullAvailVirtual; + return true; #else // Limit to 1400m because of the 2gb address space wall - return MIN2(size, (julong)1400*M); + *limit = MIN2((julong)1400*M, (julong)ms.ullAvailVirtual); + return true; #endif }