Fix the unit of meminfo

This commit is contained in:
Fabing Li
2025-01-16 08:36:58 +00:00
committed by Tate, Hongliang Tian
parent ae02eb227d
commit aa5bc6ff73

View File

@ -40,9 +40,13 @@ fn mem_available() -> usize {
impl FileOps for MemInfoFileOps {
fn data(&self) -> Result<Vec<u8>> {
let total = mem_total();
let available = mem_available();
let output = format!("MemTotal:\t{}\nMemAvailable:\t{}\n", total, available);
let total = mem_total() / 1024;
let available = mem_available() / 1024;
let free = total - available;
let output = format!(
"MemTotal:\t{} kB\nMemFree:\t{} kB\nMemAvailable:\t{} kB\n",
total, free, available
);
Ok(output.into_bytes())
}
}