mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8025942: os::Bsd::available_memory() needs implementation
Implement using the host_statistics64() api. Reviewed-by: dsamersoff, morris, dholmes, coleenp, hseigel, dcubed
This commit is contained in:
parent
6e756e193c
commit
db171c7b5d
1 changed files with 14 additions and 2 deletions
|
@ -159,9 +159,21 @@ julong os::available_memory() {
|
|||
return Bsd::available_memory();
|
||||
}
|
||||
|
||||
// available here means free
|
||||
julong os::Bsd::available_memory() {
|
||||
// XXXBSD: this is just a stopgap implementation
|
||||
return physical_memory() >> 2;
|
||||
uint64_t available = physical_memory() >> 2;
|
||||
#ifdef __APPLE__
|
||||
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
|
||||
vm_statistics64_data_t vmstat;
|
||||
kern_return_t kerr = host_statistics64(mach_host_self(), HOST_VM_INFO64,
|
||||
(host_info64_t)&vmstat, &count);
|
||||
assert(kerr == KERN_SUCCESS,
|
||||
"host_statistics64 failed - check mach_host_self() and count");
|
||||
if (kerr == KERN_SUCCESS) {
|
||||
available = vmstat.free_count * os::vm_page_size();
|
||||
}
|
||||
#endif
|
||||
return available;
|
||||
}
|
||||
|
||||
julong os::physical_memory() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue