src/os/bsd/vm/os_bsd.cpp

changeset 5895
3e265ce4d2dd
parent 5834
faff125a1ead
child 6015
e006d2e25bc7
child 6026
e4f478e7781b
     1.1 --- a/src/os/bsd/vm/os_bsd.cpp	Fri Oct 11 22:22:19 2013 -0400
     1.2 +++ b/src/os/bsd/vm/os_bsd.cpp	Sat Oct 12 13:09:18 2013 -0400
     1.3 @@ -159,9 +159,21 @@
     1.4    return Bsd::available_memory();
     1.5  }
     1.6  
     1.7 +// available here means free
     1.8  julong os::Bsd::available_memory() {
     1.9 -  // XXXBSD: this is just a stopgap implementation
    1.10 -  return physical_memory() >> 2;
    1.11 +  uint64_t available = physical_memory() >> 2;
    1.12 +#ifdef __APPLE__
    1.13 +  mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
    1.14 +  vm_statistics64_data_t vmstat;
    1.15 +  kern_return_t kerr = host_statistics64(mach_host_self(), HOST_VM_INFO64,
    1.16 +                                         (host_info64_t)&vmstat, &count);
    1.17 +  assert(kerr == KERN_SUCCESS,
    1.18 +         "host_statistics64 failed - check mach_host_self() and count");
    1.19 +  if (kerr == KERN_SUCCESS) {
    1.20 +    available = vmstat.free_count * os::vm_page_size();
    1.21 +  }
    1.22 +#endif
    1.23 +  return available;
    1.24  }
    1.25  
    1.26  julong os::physical_memory() {

mercurial