darwin: better heuristic for available memory (#4908)
Fixes: https://github.com/libuv/libuv/issues/3897
This commit is contained in:
parent
f3ce527ea9
commit
a944c422cc
@ -126,7 +126,15 @@ uint64_t uv_get_constrained_memory(void) {
|
||||
|
||||
|
||||
uint64_t uv_get_available_memory(void) {
|
||||
return uv_get_free_memory();
|
||||
vm_statistics_data_t info;
|
||||
mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t);
|
||||
|
||||
if (host_statistics(mach_host_self(), HOST_VM_INFO,
|
||||
(host_info_t)&info, &count) != KERN_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((uint64_t) info.free_count + (uint64_t) info.inactive_count + (uint64_t) info.purgeable_count) * sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user