Skip to content

Commit

Permalink
fix: incorrect memory info free/available bytes on mac (#27460)
Browse files Browse the repository at this point in the history
Fixes #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.
  • Loading branch information
nathanwhit authored Dec 24, 2024
1 parent 1a809b8 commit a9ab7a8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions runtime/sys_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,9 @@ pub fn mem_info() -> Option<MemInfo> {
// 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;
}
}
}
Expand Down

0 comments on commit a9ab7a8

Please sign in to comment.