1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-08 07:08:27 -05:00

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.
This commit is contained in:
Nathan Whitaker 2024-12-24 00:48:00 -05:00 committed by GitHub
parent 1a809b8115
commit a9ab7a80da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}
}
}