src/os/windows/vm/os_windows.cpp

Print this page




 668 
 669 
 670 julong os::available_memory() {
 671   return win32::available_memory();
 672 }
 673 
 674 julong os::win32::available_memory() {
 675   // Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect
 676   // value if total memory is larger than 4GB
 677   MEMORYSTATUSEX ms;
 678   ms.dwLength = sizeof(ms);
 679   GlobalMemoryStatusEx(&ms);
 680 
 681   return (julong)ms.ullAvailPhys;
 682 }
 683 
 684 julong os::physical_memory() {
 685   return win32::physical_memory();
 686 }
 687 
 688 julong os::allocatable_physical_memory(julong size) {



 689 #ifdef _LP64
 690   return size;

 691 #else
 692   // Limit to 1400m because of the 2gb address space wall
 693   return MIN2(size, (julong)1400*M);

 694 #endif
 695 }
 696 
 697 // VC6 lacks DWORD_PTR
 698 #if _MSC_VER < 1300
 699 typedef UINT_PTR DWORD_PTR;
 700 #endif
 701 
 702 int os::active_processor_count() {
 703   DWORD_PTR lpProcessAffinityMask = 0;
 704   DWORD_PTR lpSystemAffinityMask = 0;
 705   int proc_count = processor_count();
 706   if (proc_count <= sizeof(UINT_PTR) * BitsPerByte &&
 707       GetProcessAffinityMask(GetCurrentProcess(), &lpProcessAffinityMask, &lpSystemAffinityMask)) {
 708     // Nof active processors is number of bits in process affinity mask
 709     int bitcount = 0;
 710     while (lpProcessAffinityMask != 0) {
 711       lpProcessAffinityMask = lpProcessAffinityMask & (lpProcessAffinityMask-1);
 712       bitcount++;
 713     }




 668 
 669 
 670 julong os::available_memory() {
 671   return win32::available_memory();
 672 }
 673 
 674 julong os::win32::available_memory() {
 675   // Use GlobalMemoryStatusEx() because GlobalMemoryStatus() may return incorrect
 676   // value if total memory is larger than 4GB
 677   MEMORYSTATUSEX ms;
 678   ms.dwLength = sizeof(ms);
 679   GlobalMemoryStatusEx(&ms);
 680 
 681   return (julong)ms.ullAvailPhys;
 682 }
 683 
 684 julong os::physical_memory() {
 685   return win32::physical_memory();
 686 }
 687 
 688 bool os::has_allocatable_memory_limit(julong& limit) {
 689   MEMORYSTATUSEX ms;
 690   ms.dwLength = sizeof(ms);
 691   GlobalMemoryStatusEx(&ms);
 692 #ifdef _LP64
 693   limit = (julong)ms.ullAvailVirtual;
 694   return true;
 695 #else
 696   // Limit to 1400m because of the 2gb address space wall
 697   limit = MIN2((julong)1400*M, (julong)ms.ullAvailVirtual);
 698   return true;
 699 #endif
 700 }
 701 
 702 // VC6 lacks DWORD_PTR
 703 #if _MSC_VER < 1300
 704 typedef UINT_PTR DWORD_PTR;
 705 #endif
 706 
 707 int os::active_processor_count() {
 708   DWORD_PTR lpProcessAffinityMask = 0;
 709   DWORD_PTR lpSystemAffinityMask = 0;
 710   int proc_count = processor_count();
 711   if (proc_count <= sizeof(UINT_PTR) * BitsPerByte &&
 712       GetProcessAffinityMask(GetCurrentProcess(), &lpProcessAffinityMask, &lpSystemAffinityMask)) {
 713     // Nof active processors is number of bits in process affinity mask
 714     int bitcount = 0;
 715     while (lpProcessAffinityMask != 0) {
 716       lpProcessAffinityMask = lpProcessAffinityMask & (lpProcessAffinityMask-1);
 717       bitcount++;
 718     }