提交 b355f668 编写于 作者: P poonam

6840305: Discrepancy in system memory details (when 4G or greater) reported by JVM and Windows OS

Summary: GlobalMemoryStatus() does not report correct memory usage when the system has more than 4gb of RAM. GlobalMemoryStatusEx() should be used in place of GlobalMemoryStatus().
Reviewed-by: kamg, coleenp
上级 6ccac5dc
......@@ -616,12 +616,13 @@ julong os::available_memory() {
}
julong os::win32::available_memory() {
// FIXME: GlobalMemoryStatus() may return incorrect value if total memory
// is larger than 4GB
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
// Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect
// value if total memory is larger than 4GB
MEMORYSTATUSEX ms;
ms.dwLength = sizeof(ms);
GlobalMemoryStatusEx(&ms);
return (julong)ms.dwAvailPhys;
return (julong)ms.ullAvailPhys;
}
julong os::physical_memory() {
......@@ -1579,16 +1580,17 @@ void os::print_memory_info(outputStream* st) {
st->print("Memory:");
st->print(" %dk page", os::vm_page_size()>>10);
// FIXME: GlobalMemoryStatus() may return incorrect value if total memory
// is larger than 4GB
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
// Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect
// value if total memory is larger than 4GB
MEMORYSTATUSEX ms;
ms.dwLength = sizeof(ms);
GlobalMemoryStatusEx(&ms);
st->print(", physical %uk", os::physical_memory() >> 10);
st->print("(%uk free)", os::available_memory() >> 10);
st->print(", swap %uk", ms.dwTotalPageFile >> 10);
st->print("(%uk free)", ms.dwAvailPageFile >> 10);
st->print(", swap %uk", ms.ullTotalPageFile >> 10);
st->print("(%uk free)", ms.ullAvailPageFile >> 10);
st->cr();
}
......@@ -3135,11 +3137,13 @@ void os::win32::initialize_system_info() {
_processor_level = si.wProcessorLevel;
_processor_count = si.dwNumberOfProcessors;
MEMORYSTATUS ms;
MEMORYSTATUSEX ms;
ms.dwLength = sizeof(ms);
// also returns dwAvailPhys (free physical memory bytes), dwTotalVirtual, dwAvailVirtual,
// dwMemoryLoad (% of memory in use)
GlobalMemoryStatus(&ms);
_physical_memory = ms.dwTotalPhys;
GlobalMemoryStatusEx(&ms);
_physical_memory = ms.ullTotalPhys;
OSVERSIONINFO oi;
oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册