src/os/linux/vm/os_linux.cpp

Print this page

        

*** 189,210 **** julong os::physical_memory() { return Linux::physical_memory(); } ! julong os::allocatable_physical_memory(julong size) { #ifdef _LP64 ! return size; #else ! julong result = MIN2(size, (julong)3800*M); ! if (!is_allocatable(result)) { // See comments under solaris for alignment considerations ! julong reasonable_size = (julong)2*G - 2 * os::vm_page_size(); ! result = MIN2(size, reasonable_size); } ! return result; ! #endif // _LP64 } //////////////////////////////////////////////////////////////////////////////// // environment support --- 189,229 ---- julong os::physical_memory() { return Linux::physical_memory(); } ! bool os::has_allocatable_memory_limit(julong& limit) { ! struct rlimit rlim; ! int getrlimit_res = getrlimit(RLIMIT_AS, &rlim); ! // if there was an error when calling getrlimit, assume that there is no limitation ! // on virtual memory. ! bool result; ! if ((getrlimit_res != 0) || (rlim.rlim_cur == RLIM_INFINITY)) { ! result = false; ! } else { ! limit = (julong)rlim.rlim_cur; ! result = true; ! } #ifdef _LP64 ! return result; #else ! // arbitrary virtual space limit for Linux found by testing. If getrlimit ! // above returned a limit, bound it with this limit. Otherwise directly use ! // it as limit. ! const julong max_virtual_limit = (julong)3800*M; ! if (result) { ! limit = MIN2(limit, max_virtual_limit); ! } else { ! limit = max_virtual_limit; ! } ! if (!is_allocatable(limit)) { // See comments under solaris for alignment considerations ! julong reasonable_limit = (julong)2*G - 2 * os::vm_page_size(); ! limit = MIN2(limit, reasonable_limit); } ! return true; ! #endif } //////////////////////////////////////////////////////////////////////////////// // environment support