src/os/windows/vm/os_windows.cpp

changeset 1312
8c79517a9300
parent 1152
c8152ae3f339
child 1397
aafa4232dfd7
     1.1 --- a/src/os/windows/vm/os_windows.cpp	Mon Jun 29 14:42:12 2009 -0700
     1.2 +++ b/src/os/windows/vm/os_windows.cpp	Thu Jul 16 18:21:40 2009 -0700
     1.3 @@ -616,12 +616,13 @@
     1.4  }
     1.5  
     1.6  julong os::win32::available_memory() {
     1.7 -  // FIXME: GlobalMemoryStatus() may return incorrect value if total memory
     1.8 -  // is larger than 4GB
     1.9 -  MEMORYSTATUS ms;
    1.10 -  GlobalMemoryStatus(&ms);
    1.11 -
    1.12 -  return (julong)ms.dwAvailPhys;
    1.13 +  // Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect
    1.14 +  // value if total memory is larger than 4GB
    1.15 +  MEMORYSTATUSEX ms;
    1.16 +  ms.dwLength = sizeof(ms);
    1.17 +  GlobalMemoryStatusEx(&ms);
    1.18 +
    1.19 +  return (julong)ms.ullAvailPhys;
    1.20  }
    1.21  
    1.22  julong os::physical_memory() {
    1.23 @@ -1579,16 +1580,17 @@
    1.24    st->print("Memory:");
    1.25    st->print(" %dk page", os::vm_page_size()>>10);
    1.26  
    1.27 -  // FIXME: GlobalMemoryStatus() may return incorrect value if total memory
    1.28 -  // is larger than 4GB
    1.29 -  MEMORYSTATUS ms;
    1.30 -  GlobalMemoryStatus(&ms);
    1.31 +  // Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect
    1.32 +  // value if total memory is larger than 4GB
    1.33 +  MEMORYSTATUSEX ms;
    1.34 +  ms.dwLength = sizeof(ms);
    1.35 +  GlobalMemoryStatusEx(&ms);
    1.36  
    1.37    st->print(", physical %uk", os::physical_memory() >> 10);
    1.38    st->print("(%uk free)", os::available_memory() >> 10);
    1.39  
    1.40 -  st->print(", swap %uk", ms.dwTotalPageFile >> 10);
    1.41 -  st->print("(%uk free)", ms.dwAvailPageFile >> 10);
    1.42 +  st->print(", swap %uk", ms.ullTotalPageFile >> 10);
    1.43 +  st->print("(%uk free)", ms.ullAvailPageFile >> 10);
    1.44    st->cr();
    1.45  }
    1.46  
    1.47 @@ -3135,11 +3137,13 @@
    1.48    _processor_level = si.wProcessorLevel;
    1.49    _processor_count = si.dwNumberOfProcessors;
    1.50  
    1.51 -  MEMORYSTATUS ms;
    1.52 +  MEMORYSTATUSEX ms;
    1.53 +  ms.dwLength = sizeof(ms);
    1.54 +
    1.55    // also returns dwAvailPhys (free physical memory bytes), dwTotalVirtual, dwAvailVirtual,
    1.56    // dwMemoryLoad (% of memory in use)
    1.57 -  GlobalMemoryStatus(&ms);
    1.58 -  _physical_memory = ms.dwTotalPhys;
    1.59 +  GlobalMemoryStatusEx(&ms);
    1.60 +  _physical_memory = ms.ullTotalPhys;
    1.61  
    1.62    OSVERSIONINFO oi;
    1.63    oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

mercurial