From a9ab7a80da2395823dfd3bc4c4f60c46b126734d Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Tue, 24 Dec 2024 00:48:00 -0500 Subject: [PATCH] fix: incorrect memory info free/available bytes on mac (#27460) Fixes https://github.com/denoland/deno/issues/27435 For some reason this was dividing by 1024 (as if the unit was KB, and we wanted bytes) but the page size is already in bytes. --- runtime/sys_info.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runtime/sys_info.rs b/runtime/sys_info.rs index f99cfc99f96b03..99bfcfe103a5f8 100644 --- a/runtime/sys_info.rs +++ b/runtime/sys_info.rs @@ -295,11 +295,9 @@ pub fn mem_info() -> Option { // TODO(@littledivy): Put this in a once_cell let page_size = libc::sysconf(libc::_SC_PAGESIZE) as u64; mem_info.available = - (stat.free_count as u64 + stat.inactive_count as u64) * page_size - / 1024; + (stat.free_count as u64 + stat.inactive_count as u64) * page_size; mem_info.free = - (stat.free_count as u64 - stat.speculative_count as u64) * page_size - / 1024; + (stat.free_count as u64 - stat.speculative_count as u64) * page_size; } } }